自定义机器人接口规范
更新时间:2026-05-09
概述
使用自有对话引擎,可以按此规范提供一个开放接口,在平台创建自定义机器人配置接口地址和token,通过机器人对话会触发此接口的调用。
请求参数
Header参数
| 名称 | 类型 | 必选 | 描述 |
|---|---|---|---|
| Content-Type | string | 是 | 内容类型,固定值:application/json |
| token | string | 是 | API KEY |
| Authorization | string | 是 | Bearer token |
Body参数
| 名称 | 类型 | 必选 | 描述 |
|---|---|---|---|
| queryText | string | 否 | 用户问题,请求的问题,比如示例中的:帮我写一首爱情的诗 |
| sessionId | string | 否 | 会话id,首轮可以为空(如果首轮传了,后续需要使用首轮传的。),首轮会返回sessionId,后续对话需要使用返回的sessionId。 |
| variables | map | 否 | 变量,key变量名称,value变量值。对话中使用的变量,默认首轮携带通话发起所有变量,通话中可能携带动态变量。 |
| silence | bool | 否 | 是否触发静默,传入true请求接口会回复机器人配置的静默话术 |
| silenceType | int | 否 | 触发的静默类型,0全局静默,1节点静默,注意如果当前节点不支持节点静默,传入1可能会导致机器人回复异常 |
- variables中可能携带的动态变量
| 变量 | 类型 | 必选 | 描述 |
|---|---|---|---|
| Trans_result | string | 否 | 转人工状态,-1转人工失败,2转人工繁忙 |
请求示例
JSON
1curl --location 'https://xxx/stream/query'
2--header 'token: xxxx'
3--header 'Authorization: Bearer token'
4--header 'Content-Type: application/json'
5--data '{
6 "queryText": "你是谁啊",
7 "sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d",
8 "variables": {
9 "homeAddress": "chengdu"
10 }
11}'
响应参数
| 名称 | 类型 | 必选 | 描述 |
|---|---|---|---|
| sessionId | string | 是 | 会话ID,用于标识会话的唯一ID |
| queryId | string | 是 | 查询ID,用于标识本次对话的唯一ID |
| answer | array | 是 | 回答列表,包含各个回答块的数组 |
| → chunkId | integer | 是 | 流式chunkId |
| → status | string | 是 | 流式返回数据状态,running(进行中),done(完成) |
| → reply | object | 否 | 回复,包含回复相关详细信息的对象 |
| → → type | integer | 是 | 回复类型,1(文本) |
| → → text | string | 是 | 回复文本 |
| → → audioURL | string | 否 | 回复文本录音地址 |
| → → replySource | string | 是 | 回复来源,FAQ(问答)、RAG(文档问答)、CHITCHAT(闲聊)、TEXT_REPLY(文本回复)、LARGE_MODEL_REPLY(大模型回复) |
| → → allowInterrupt | bool | 否 | 是否允许打断 |
| → → allowSemanticInterruption | bool | 否 | 是否允许语义打断 |
| → instruction | map | 否 | 指令,key为指令标识,value为指令参数 |
| identifyDuration | int | 否 | vad设置时长,单位ms,第一个数据包中更新,有效值 > 0 |
| nodeSilentDurationSeconds | int | 否 | 节点静默时长,单位s,有效值 > 0 |
指令列表
| 指令标识 | 指令参数 | 描述 | |
|---|---|---|---|
| system_hangup | - | 挂机,由机器人触发的结束通话指令 | |
| system_blacklist_event | - | 黑名单,将当前通话被叫号码添加到黑名单列表,后续不再呼叫 | |
| system_shortmessage | {"mobile":"12345678","signatureId":"47284801","templateId":"30340608"} | 发送短信,发送短信通知,签名和模版需要从外呼平台获取mobile:用户号码signatureId:短信签名templateId:短信模版 | |
| system_toCustomerService | {"transAddr":"1001@10.10.10.10:5060","transType":"3","transValue":"12345678"} | 转人工服务,转接通话给人工客服transAddr:转接地址,sip协议地址transType:转接类型,1:转座席;2:转技能组;3:转号码transValue:转接值,对应类型的技能组名称,坐席工号或者转接的号码 |
响应示例
JSON
1{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 0,"status": "running","reply": {"type": 1,"text": "我","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}], "identifyDuration": 800, "nodeSilentDurationSeconds": 1000}
2{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 1,"status": "running","reply": {"type": 1,"text": "呀","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
3{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 2,"status": "running","reply": {"type": 1,"text": ",是","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
4{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 3,"status": "running","reply": {"type": 1,"text": "坐席","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
5{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 4,"status": "running","reply": {"type": 1,"text": "中心","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
6{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 5,"status": "running","reply": {"type": 1,"text": "的小助手","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
7{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 6,"status": "running","reply": {"type": 1,"text": ",专门","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
8{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 7,"status": "running","reply": {"type": 1,"text": "来陪你","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
9{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 8,"status": "running","reply": {"type": 1,"text": "聊天","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
10{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 9,"status": "running","reply": {"type": 1,"text": "、","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
11{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 10,"status": "running","reply": {"type": 1,"text": "帮你解决问题的","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
12{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 11,"status": "running","reply": {"type": 1,"text": ",","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
13{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 12,"status": "running","reply": {"type": 1,"text": "有啥事儿","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
14{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 13,"status": "running","reply": {"type": 1,"text": "尽管说","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
15{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 14,"status": "running","reply": {"type": 1,"text": "~","audioUrl": null,"replySource": "CHITCHAT", "allowInterrupt": true, "allowSemanticInterruption": true}}]}
16{"sessionId": "3_f7de7ec487694bc7bf2f64cf309cbd8d","queryId": "7c0cd473-aba6-44e1-b84c-04890415cb9c","answer": [{"chunkId": 15,"status": "done","reply": {"type": 1,"text": "","audioUrl": null,"replySource": "CHITCHAT","allowInterrupt": true,"allowSemanticInterruption": true},"instruction": {"system_hangup": null,"system_shortmessage": {"mobile": "12345678","signatureId": "47284801","templateId": "30340608"}}}]}
评价此篇文章
