Skip to main content

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 ProvidedIBot Method NameDescription
POST /v1/aibot/bots/:botId/send-messagesendMessageConverse with Agent
POST /v1/aibot/bots/:botId/wx-send-messagewxSendMessageConverse with Agent (WeChat callback)
GET /v1/aibot/bots/:botIdgetBotInfoQuery Agent configuration information
GET /v1/aibot/bots/:botId/recordsgetChatRecordsQuery Agent historical conversation records
POST /v1/aibot/bots/:botId/recommend-questionsgetRecommendQuestionsObtain recommended questions
POST /v1/aibot/bots/:botId/feedbacksendFeedbackSubmit user feedback
GET /v1/aibot/bots/:botId/feedbackgetFeedbackQuery user feedback
POST /v1/aibot/bots/:botId/speech-to-textspeechToTextSpeech to Text
POST /v1/aibot/bots/:botId/text-to-speechtextToSpeechText to Speech
GET /v1/aibot/bots/:botId/text-to-speechgetTextToSpeechResultGet Text-to-Speech result
POST /v1/aibot/bots/:botId/conversationcreateConversationCreate conversation
GET /v1/aibot/bots/:botId/conversationgetConversationQuery conversation
PATCH /v1/aibot/bots/:botId/conversation/:conversationupdateConversationUpdate conversation
DELETE /v1/aibot/bots/:botId/conversation/:conversationdeleteConversationDelete 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

WxSendMessageInput

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()?

optional getChatRecords(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()?

optional getFeedback(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()?

optional getRecommendQuestions(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()?

optional sendFeedback(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

SendFeedbackInput

Returns

Promise\<SendFeedbackOutput>


speechToText()?

optional speechToText(input): Promise\<SpeechToTextOutput>

speechToText - POST /v1/aibot/bots/:botId/speechToText

Speech to Text

Parameters

See the HTTP API documentation for call parameters.


textToSpeech()?

optional textToSpeech(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()?

optional getTextToSpeechResult(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()?

optional createConversation(): Promise\<CreateConversationOutput>

conversation - POST /v1/aibot/bots/:botId/conversation

Create Session

Parameters

See the HTTP API documentation for call parameters.


getConversation()?

optional getConversation(input): Promise\<GetConversationOutput>

conversation - GET /v1/aibot/bots/:botId/conversation

Query Session

Parameters

input

GetConversationInput

Returns

Promise\<GetConversationOutput>


updateConversation()?

optional updateConversation(input): Promise\<UpdateConversationOutput>

conversation - PATCH /v1/aibot/bots/:botId/conversation/:conversation

Update Session

Parameters

input

UpdateConversationInput

Returns

Promise\<UpdateConversationOutput>


deleteConversation()?

optional deleteConversation(input): Promise\<DeleteConversationOutput>

conversation - DELETE /v1/aibot/bots/:botId/conversation/:conversation

Delete Session

Parameters

input

DeleteConversationInput

Returns

Promise\<DeleteConversationOutput>


Type

GetChatRecordOutput

Properties

recordList

recordList: object[]

botId?

optional botId: string

content?

optional content: string

conversation?

optional conversation: string

createTime?

optional createTime: string

image?

optional image: string

recordId?

optional recordId: string

reply?

optional reply: string

replyTo?

optional replyTo: string

role?

optional role: string

triggerSrc?

optional triggerSrc: string

type?

optional type: 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?

optional history: 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

optional triggerSrc: string

wxVerify?

WeChat APPID authentication status

optional wxVerify: boolean


WeChatTextOutput

Properties

Content?

optional Content: string

CreateTime?

optional CreateTime: number

FromUserName?

optional FromUserName: string

MsgType?

optional MsgType: string

ToUserName?

optional ToUserName: 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?

optional conversationId: string

limit?

optional limit: number

offset?

optional offset: number


GetConversationOutput

Properties

data

data: object[]

conversationId

conversationId: string

createTime

createTime: string

title

title: string

updateTime

updateTime: string

total

total: number


UpdateConversationInput

Properties

conversationId?

optional conversationId: string

title

title: string


UpdateConversationOutput

Properties

count

count: number


DeleteConversationInput

Properties

conversationId

conversationId: string


DeleteConversationOutput

Properties

count

count: number


GetBotInfoOutput

Properties

agentSetting?

optional agentSetting: string

avatar?

optional avatar: string

background?

optional background: string

botId?

optional botId: string

databaseModel?

optional databaseModel: string[]

initQuestions?

optional initQuestions: string[]

introduction?

optional introduction: string

isNeedRecommend?

optional isNeedRecommend: boolean

knowledgeBase?

optional knowledgeBase: string[]

mcpServerList?

optional mcpServerList: object[]

name?

optional name: string

tools

tools: object[]

url?

optional url: string

model?

optional model: string

modelValue?

optional modelValue: string

multiConversationEnable?

optional multiConversationEnable: boolean

name?

optional name: string

searchEnable?

optional searchEnable: boolean

searchFileEnable?

optional searchFileEnable: boolean

tags?

optional tags: string[]

type?

optional type: string

updateTime?

optional updateTime: number

voiceSettings?

optional voiceSettings: object

enable?

optional enable: boolean

inputType?

optional inputType: string

outputType?

optional outputType: number

welcomeMessage?

optional welcomeMessage: string