Golang Bot SDK

A Golang server-side Bot SDK

This Bot SDK enables developers to create chatbots for managing chat groups. You can develop a bot capable of managing group chats using various standards, such as token-gated chats which can be useful for managing exclusive or private groups.

Create custom chatbots tailored to your needs and add them seamlessly to the existing chat groups. This can save time and effort, as well as improve the efficiency and effectiveness of chat group management.

Install

go get github.com/sending-network/sendingnetwork-bot

Usage

Prepare a configuration file

Please contact developer@sending.network for a test P2P node URL.

Provide P2P node endpoint, wallet address and private key in config.yaml:

endpoint: ""
wallet_address: ""
private_key: ""

You can use an existing wallet account, or generate a new account by running:

go run tools/generate_wallet_account.go

Create an instance of Client

After reading the configuration file, create an instance of Client

package main

import (
  "os"
  
  sdnclient "github.com/sending-network/sendingnetwork-bot"
  "gopkg.in/yaml.v3"
)

func main() {
    configData, _ := os.ReadFile("config.yaml")
    config := sdnclient.Config{}
    _ = yaml.Unmarshal(configData, &config)
    cli, _ := sdnclient.NewClient(&config)
}

Call API functions

// create new room
respCreateRoom, _ := cli.CreateRoom(&sdnclient.ReqCreateRoom{
  Name:   "TestRoom",
})

// invite user to the room
respInviteUser, _ := cli.InviteUser(respCreateRoom.RoomID, &sdnclient.ReqInviteUser{
    UserID: userID,
})

// logout to invalidate access token
respLogout, _ := cli.Logout()

Examples

You can see more use cases in the examples directory.

License

Apache 2.0

Last updated