IBot
The Function-based Agent Framework provides the IBot interface. Developers can deploy corresponding services simply by implementing a class that conforms to IBot.
The complete method definitions of IBot and the corresponding services are as follows:
| Services Provided | IBot Method Name | Description |
|---|---|---|
POST /v1/aibot/bots/:botId/send-message | sendMessage | Converse with Agent |
POST /v1/aibot/bots/:botId/wx-send-message | wxSendMessage | Converse with Agent (WeChat callback) |
GET /v1/aibot/bots/:botId | getBotInfo | Query Agent configuration information |
GET /v1/aibot/bots/:botId/records | getChatRecords | Query Agent historical conversation records |
POST /v1/aibot/bots/:botId/recommend-questions | getRecommendQuestions | Obtain recommended questions |
POST /v1/aibot/bots/:botId/feedback | sendFeedback | Submit user feedback |
GET /v1/aibot/bots/:botId/feedback | getFeedback | Query user feedback |
POST /v1/aibot/bots/:botId/speech-to-text | speechToText | Speech to Text |
POST /v1/aibot/bots/:botId/text-to-speech | textToSpeech | Text to Speech |
GET /v1/aibot/bots/:botId/text-to-speech | getTextToSpeechResult | Get Text-to-Speech result |
POST /v1/aibot/bots/:botId/conversation | createConversation | Create conversation |
GET /v1/aibot/bots/:botId/conversation | getConversation | Query conversation |
PATCH /v1/aibot/bots/:botId/conversation/:conversation | updateConversation | Update conversation |
DELETE /v1/aibot/bots/:botId/conversation/:conversation | deleteConversation | Delete conversation |
Using the BotCore base class enables faster implementation of the IBot interface.
Methods
sendMessage()
sendMessage(
input):Promise<void>
sendMessage - POST /v1/aibot/bots/:botId/send-message
Implementation of the Q&A dialogue interface with the Agent. This interface has no return value and must send Server-Sent Events to the client via this.sseSender within the implementation.
The corresponding interface for the WeChat Basic Library wx.cloud.extend.AI.bot.sendMessage API
Parameters
See the HTTP API documentation for call parameters.
wxSendMessage()
wxSendMessage(
input):Promise<WeChatTextOutput>
wxSendMessage - POST /v1/aibot/bots/:botId/wx-send-message
After WeChat integration, the implementation of the WeChat customer service message callback Agent interface returns responses based on the WeChat APPID type and authentication status.
Parameters
input
Returns
Promise<WeChatTextOutput>
getBotInfo()
getBotInfo(
input):Promise<GetBotInfoOutput>
getBotInfo - POST /v1/aibot/bots/:botId
Obtain Agent configuration, return Agent information
The counterpart interface for the WeChat Basic Library wx.cloud.extend.AI.bot.get API
https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/reference-sdk-api/extend/ai.html#AI-bot-get
Parameters
See the HTTP API documentation for call parameters.
getChatRecords()?
optionalgetChatRecords(input):Promise<GetChatRecordOutput>
getChatRecords - GET /v1/aibot/bots/:botId/records
Implementation of the query Agent historical conversation information interface, returning historical conversation records.
Note: The sendMessage interface must implement conversation recording, and this interface queries and returns the conversation records.
The corresponding interface for the WeChat Basic Library wx.cloud.extend.AI.bot.getChatRecords API
Parameters
See the HTTP API documentation for call parameters.
getFeedback()?
optionalgetFeedback(input):Promise<GetFeedbackOutput>
getFeedback - GET /v1/aibot/bots/:botId/feedback
Implementation of the obtain user feedback interface, returning a user-feedback list.
The corresponding interface for the WeChat Basic Library wx.cloud.extend.AI.bot.getFeedBack API
Parameters
See the HTTP API documentation for call parameters.
getRecommendQuestions()?
optionalgetRecommendQuestions(input):Promise<void>
getRecommendQuestions - POST /v1/aibot/bots/:botId/recommend-questions
Implementation of the obtain recommended questions interface, returning a recommended-questions list.
The corresponding interface for the WeChat Basic Library wx.cloud.extend.AI.bot.getRecommendQuestions API
Parameters
See the HTTP API documentation for call parameters.
sendFeedback()?
optionalsendFeedback(input):Promise<SendFeedbackOutput>
sendFeedback - POST /v1/aibot/bots/:botId/feedback
Implementation of the send user feedback interface, returning the result of sending user feedback.
The corresponding interface for the WeChat Basic Library wx.cloud.extend.AI.bot.sendFeedback API
Parameters
input
Returns
Promise<SendFeedbackOutput>
speechToText()?
optionalspeechToText(input):Promise<SpeechToTextOutput>
speechToText - POST /v1/aibot/bots/:botId/speechToText
Speech to Text
Parameters
See the HTTP API documentation for call parameters.
textToSpeech()?
optionaltextToSpeech(input):Promise<TextToSpeechOutput>
text-to-speech - POST /v1/aibot/bots/:botId/text-to-speech
Text to Speech
Parameters
See the HTTP API documentation for call parameters.
getTextToSpeechResult()?
optionalgetTextToSpeechResult(input):Promise<GetTextToSpeechResultOutput>
text-to-speech - GET /v1/aibot/bots/:botId/text-to-speech
Obtain Text to Speech result
Parameters
See the HTTP API documentation for call parameters.
createConversation()?
optionalcreateConversation():Promise<CreateConversationOutput>
conversation - POST /v1/aibot/bots/:botId/conversation
Create Session
Parameters
See the HTTP API documentation for call parameters.
getConversation()?
optionalgetConversation(input):Promise<GetConversationOutput>
conversation - GET /v1/aibot/bots/:botId/conversation
Query Session
Parameters
input
Returns
Promise<GetConversationOutput>
updateConversation()?
optionalupdateConversation(input):Promise<UpdateConversationOutput>
conversation - PATCH /v1/aibot/bots/:botId/conversation/:conversation
Update Session
Parameters
input
Returns
Promise<UpdateConversationOutput>
deleteConversation()?
optionaldeleteConversation(input):Promise<DeleteConversationOutput>
conversation - DELETE /v1/aibot/bots/:botId/conversation/:conversation
Delete Session
Parameters
input
Returns
Promise<DeleteConversationOutput>
Type
GetChatRecordOutput
Properties
recordList
recordList:
object[]
botId?
optionalbotId:string
content?
optionalcontent:string
conversation?
optionalconversation:string
createTime?
optionalcreateTime:string
image?
optionalimage:string
recordId?
optionalrecordId:string
reply?
optionalreply:string
replyTo?
optionalreplyTo:string
role?
optionalrole:string
triggerSrc?
optionaltriggerSrc:string
type?
optionaltype:string
total
total:
number
GetFeedbackOutput
Properties
feedbackList
feedbackList:
object[]
aiAnswer
aiAnswer:
string
botId
botId:
string
comment
comment:
string
createTime
createTime:
string
input
input:
string
rating
rating:
number