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
sender
sender:
string
tags
tags:
string[]
type
type:
string
total
total:
number
SendFeedbackInput
Properties
aiAnswer
aiAnswer:
string
comment
comment:
string
input
input:
string
rating
rating:
number
recordId
recordId:
string
tags
tags:
string[]
type
type:
string
SendFeedbackOutput
Properties
status
status:
"success"
SendMessageInput
Properties
history?
optionalhistory:object[]
content
content:
string
role
role:
"user"|"assistant"
msg
msg:
string
WeChatTextInput
Properties
content
content:
string
createTime
createTime:
number
fromUserName
fromUserName:
string
msgId
msgId:
string
msgType
msgType:
string
toUserName
toUserName:
string
WeChatVoiceInput
Properties
createTime
createTime:
number
format
format:
string
fromUserName
fromUserName:
string
mediaId
mediaId:
string
msgId
msgId:
string
msgType
msgType:
string
toUserName
toUserName:
string
WeChatWorkTextInput
Properties
externalUserId
externalUserId:
string
msgId
msgId:
string
msgType
msgType:
string
openKfId
openKfId:
string
origin
origin:
number
sendTime
sendTime:
number
text
text:
object
content
content:
string
WeChatWorkVoiceInput
Properties
externalUserId
externalUserId:
string
msgId
msgId:
string
msgType
msgType:
string
openKfId
openKfId:
string
origin
origin:
number
sendTime
sendTime:
number
voice
voice:
object
mediaId
mediaId:
string
WxSendMessageInput
Properties
callbackData
WeChat callback message
callbackData:
WeChatTextInput|WeChatVoiceInput|WeChatWorkTextInput|WeChatWorkVoiceInput
triggerSrc?
According to the WeChat APPID source type: WeChat Subscription Account: WXSubscription, WeChat Service Account: WXService, WeChat Mini Program Customer Service: WXMiniapp, WeCom Customer Service: WXCustomerService
optionaltriggerSrc:string
wxVerify?
WeChat APPID authentication status
optionalwxVerify:boolean
WeChatTextOutput
Properties
Content?
optionalContent:string
CreateTime?
optionalCreateTime:number
FromUserName?
optionalFromUserName:string
MsgType?
optionalMsgType:string
ToUserName?
optionalToUserName:string
SpeechToTextInput
Properties
engSerViceType
input language type
engSerViceType:
string
url
Voice file link
url:
string
voiceFormat
Identify audio format, such as wav/mp3
voiceFormat:
string
SpeechToTextOutput
Properties
Result
Result:
string
TextToSpeechOutput
Properties
TaskId
TaskId:
string
GetTextToSpeechResultOutput
Properties
ResultUrl
ResultUrl:
string
Status
Status:
number
StatusStr
StatusStr:
string
TaskId
TaskId:
string
CreateConversationOutput
Properties
conversationId
conversationId:
string
title
title:
string
GetConversationInput
Properties
conversationId?
optionalconversationId:string
limit?
optionallimit:number
offset?
optionaloffset:number
GetConversationOutput
Properties
data
data:
object[]
conversationId
conversationId:
string
createTime
createTime:
string
title
title:
string
updateTime
updateTime:
string
total
total:
number
UpdateConversationInput
Properties
conversationId?
optionalconversationId:string
title
title:
string
UpdateConversationOutput
Properties
count
count:
number
DeleteConversationInput
Properties
conversationId
conversationId:
string
DeleteConversationOutput
Properties
count
count:
number
GetBotInfoOutput
Properties
agentSetting?
optionalagentSetting:string
avatar?
optionalavatar:string
background?
optionalbackground:string
botId?
optionalbotId:string
databaseModel?
optionaldatabaseModel:string[]
initQuestions?
optionalinitQuestions:string[]
introduction?
optionalintroduction:string
isNeedRecommend?
optionalisNeedRecommend:boolean
knowledgeBase?
optionalknowledgeBase:string[]
mcpServerList?
optionalmcpServerList:object[]
name?
optionalname:string
tools
tools:
object[]
url?
optionalurl:string
model?
optionalmodel:string
modelValue?
optionalmodelValue:string
multiConversationEnable?
optionalmultiConversationEnable:boolean
name?
optionalname:string
searchEnable?
optionalsearchEnable:boolean
searchFileEnable?
optionalsearchFileEnable:boolean
tags?
optionaltags:string[]
type?
optionaltype:string
updateTime?
optionalupdateTime:number
voiceSettings?
optionalvoiceSettings:object
enable?
optionalenable:boolean
inputType?
optionalinputType:string
outputType?
optionaloutputType:number
welcomeMessage?
optionalwelcomeMessage:string