Documentation
¶
Overview ¶
Golang SDK for Sarufi Conversational AI Platform
Index ¶
- type Actions
- type Application
- func (app *Application) CreateBot(name, description, industry string, visible bool) (*Bot, error)
- func (app *Application) DeleteBot(id int) error
- func (app *Application) GetAllBots() ([]Bot, error)
- func (app *Application) GetBot(id int) (*Bot, error)
- func (app *Application) GetUser() (*User, error)
- func (app *Application) SetToken(apiKey string)
- func (app *Application) UpdateBot(bot *Bot) error
- type Bot
- func (bot *Bot) AddFlow(node string, flow interface{}) error
- func (bot *Bot) AddIntent(title string, message []string) error
- func (bot *Bot) ChatState() error
- func (bot *Bot) CreateFlows(flows string) error
- func (bot *Bot) CreateIntents(intents string) error
- func (bot *Bot) DeleteFlow(title string) error
- func (bot *Bot) DeleteIntent(title string) error
- func (bot *Bot) GetChatHistory(chatID string) error
- func (bot *Bot) GetChatUsers() error
- func (bot *Bot) Predict(message string) error
- func (bot *Bot) Respond(message, channel string) error
- type ChatUser
- type ConflictError
- type Conversation
- type ConversationHistory
- type ConversationWithKnowledge
- type CustomTime
- type Detail
- type Memory
- type NotFoundError
- type Prediction
- type Response
- type Unauthorized
- type UnprocessableEntity
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶ added in v0.2.0
type Application struct {
User User `json:"user"`
}
Application will hold all application methods. It also has details about the user
func (*Application) CreateBot ¶ added in v0.2.0
func (app *Application) CreateBot(name, description, industry string, visible bool) (*Bot, error)
CreateBot method to create a new bot. It accepts the following parameters: Name (type string) - which is the name of the bot Description (type string)- which is the description of the bot Industry (type string) - which is the related industry of the bot Visible (type bool) - allow it to be publicly available It returns a pointer to a new Bot and an error
func (*Application) DeleteBot ¶ added in v0.2.0
func (app *Application) DeleteBot(id int) error
DeleteBot() will delete the bot of with provided ID. It will return an error if deletion was unsuccessful
func (*Application) GetAllBots ¶ added in v0.2.0
func (app *Application) GetAllBots() ([]Bot, error)
GetBots() method returns a list of type Bot and an error
func (*Application) GetBot ¶ added in v0.2.0
func (app *Application) GetBot(id int) (*Bot, error)
GetBot() method to get a specific bot. It accepts the bot id (type int) as a parameter. Returns a pointer of type Bot and an error.
func (*Application) GetUser ¶ added in v0.2.0
func (app *Application) GetUser() (*User, error)
Get user's information
func (*Application) SetToken ¶ added in v0.3.0
func (app *Application) SetToken(apiKey string)
GetToken() method to generate a token for the user. The received token will be saved to Application.Token otherwise it will return an error.
func (*Application) UpdateBot ¶ added in v0.2.0
func (app *Application) UpdateBot(bot *Bot) error
UpdateBot() method to update the bot. It accepts a parameter of type *Bot and will return an error if any
type Bot ¶
type Bot struct {
Id int `json:"id"`
Name string `json:"name"`
Industry string `json:"industry"`
Description string `json:"description"`
UserID int `json:"user_id"`
VisibleOnCommunity bool `json:"visible_on_community"`
Intents map[string][]string `json:"intents"`
Flows map[string]interface{} `json:"flows"`
ModelName string `json:"model_name"`
WebhookURL string `json:"webhook_url"`
WebhookTriggerIntents []string `json:"webhook_trigger_intents"`
EvaluationMetrics interface{} `json:"evaluation_metrics"`
ChatID string `json:"chat_id"`
Conversation Conversation
ConversationWithKnowledge ConversationWithKnowledge
Prediction Prediction
ChatUsers []ChatUser
ConversationHistory []ConversationHistory `json:"conversation_history"`
}
Type Bot. All the fields are matched to the API JSON response. You can read more here https://neurotech-africa.stoplight.io/docs/sarufi/a3135fbb09470-create-new-chatbot
func (*Bot) AddFlow ¶
AddFlow method to add a new flow. It accepts a string that will be the title of the flow and an interface. To allow ability to add choices, flow has been made an interface. See: https://docs.sarufi.io/docs/Getting%20started%20/chatbots-addons#handling-choices
func (*Bot) AddIntent ¶
AddIntent method to add a new intent. It accepts a string that will be the title of the intent, and a slice of message strings that will be the intent content.
func (*Bot) ChatState ¶
To get the current and next state of the chat. It accepts no parameters. It will display the JSON response from the API.
func (*Bot) CreateFlows ¶
CreateFlows method to create a new flow. It accepts a string that contains the flows arranged in JSON format. It also acceps a json file (eg: flows.json)
func (*Bot) CreateIntents ¶
CreateIntents method to create a new intent. It accepts a string that contains the intents arranged in JSON format. It also acceps a json file (eg: intents.json). It will return an error if any.
func (*Bot) DeleteFlow ¶
DeleteFlow method to delete a specific flow. The accepted string is the title of the flow. If the title does not exist no error will be displayed.
func (*Bot) DeleteIntent ¶
DeleteIntent method to delete a specific intent. The accepted string is the title of the intent. If the title does not exist no error will be displayed.
func (*Bot) GetChatHistory ¶ added in v0.2.0
Get conversation history of a particular ChatID. The result will be stored at the bot.ConversationHistory.
func (*Bot) GetChatUsers ¶ added in v0.2.0
A method to get all users communicating with the bot. A list of chat users will be stored at bot.ChatUsers field.
type ConflictError ¶ added in v0.2.0
type ConflictError struct {
Detail Detail `json:"detail"`
}
func (*ConflictError) Error ¶ added in v0.2.0
func (c *ConflictError) Error() string
type Conversation ¶ added in v0.2.0
type Conversation struct {
Message []string `json:"message"`
Memory Memory `json:"memory"`
NextState string `json:"next_state"`
}
Conversation will hold all conversation related data on none knowledge base bot
type ConversationHistory ¶ added in v0.2.0
type ConversationHistory struct {
ID int `json:"id"`
Message string `json:"message"`
Sender string `json:"sender"`
Response []Response `json:"response"`
ReceivedTime string `json:"received_time"`
}
This type will hold information of the converstion of a particular chat ID
type ConversationWithKnowledge ¶ added in v0.3.3
type ConversationWithKnowledge struct {
Message []Actions `json:"actions"`
Memory Memory `json:"memory"`
NextState string `json:"next_state"`
}
ConversationWithKnowledge will hold all conversation related data on knowledge base bot
type CustomTime ¶ added in v0.2.0
ToDo; Make custom way of parsing time
func (*CustomTime) UnmarshalJSON ¶ added in v0.2.0
func (m *CustomTime) UnmarshalJSON(data []byte) error
type NotFoundError ¶ added in v0.2.0
func (*NotFoundError) Error ¶ added in v0.2.0
func (nf *NotFoundError) Error() string
type Prediction ¶ added in v0.2.0
type Prediction struct {
Message string `json:"message"`
Intent string `json:"intent"`
Status bool `json:"status"`
Confidence float64 `json:"confidence"`
}
Prediction will hold the response of a paritcular intent prediction
type Response ¶ added in v0.2.0
type Response struct {
Message []string `json:"send_message"`
}
This type will be used in the conversation history
type Unauthorized ¶ added in v0.2.0
type Unauthorized struct {
}
func (*Unauthorized) Error ¶ added in v0.2.0
func (ua *Unauthorized) Error() string
type UnprocessableEntity ¶ added in v0.2.0
type UnprocessableEntity struct {
Detail []Detail `json:"detail"`
}
func (*UnprocessableEntity) Error ¶ added in v0.2.0
func (ue *UnprocessableEntity) Error() string