在线机器人机器人会话
发送访客消息
发送访客消息。
接口级参数规则:uid、productId、fromType、msg 必填;msgType 与 msgBody 结构需匹配。
请求字段限制:
- uid:必填,访客在调用方系统里的唯一标识
- productId:必填,当前咨询应用唯一标识
- fromType:必填,当前访客咨询来源渠道
- robotId:选填,机器人 ID,存在多个机器人时指定
- msg:必填,访客消息,目前支持 text、image、audio、workflow 等类型
- skipTrans:选填,是否跳过转人工逻辑判断:0-不跳过,1-跳过,默认值:0
请求参数
| 名称 | 类型 | 必填 | 描述 | 示例值 |
|---|---|---|---|---|
| appKey | string | 是 | 应用 AppKey | 1c088a89de51d0af457616605f28390f |
| time | int64 | 是 | 请求时间戳(秒);与服务器时间误差超过 10 分钟会鉴权失败 | 1511832531 |
| checksum | string | 是 | 请求签名校验和 | f570a5eb049eb803b086e45829b07e48 |
| checksumAlgorithm | int32 | 否 | 签名算法:0-SHA-1,1-SHA-256;不传默认为 0(SHA-1) | 0 |
请求体
| 名称 | 类型 | 必填 | 描述 | 示例值 |
|---|---|---|---|---|
| uid | string | 是 | 访客在调用方系统里的唯一标识 | user-001 |
| productId | string | 是 | 当前咨询应用唯一标识 | com.example.app |
| fromType | string | 是 | 当前访客咨询来源渠道 | web |
| robotId | int64 | 否 | 机器人 ID,存在多个机器人时指定 | 123456 |
| msg | object | 是 | 开放接口消息体 | |
| └msgType | string | 否 | 消息类型:text、richtext、image、video、audio、workflow | text |
| └msgBody | object | 否 | 消息内容。text/richtext 类型使用 TextMessageBody,其它类型按对应消息体协议传入 | |
| skipTrans | int32 | 否 | 是否跳过转人工逻辑判断:0-不跳过,1-跳过 | 0 |
返回参数
| 名称 | 类型 | 描述 | 示例值 |
|---|---|---|---|
| code | int32 | 业务状态码,200 表示成功 | 200 |
| message | string | 响应消息 | success |
| data | object | ||
| └sessionId | int64 | 会话 ID | |
| └userId | int64 | 访客对应七鱼用户账号 ID | |
| └robotId | int64 | 机器人 ID | |
| └answerList | object[] | 机器人多条答案列表 | |
| └msgId | string | 消息 ID | |
| └ansType | int32 | 机器人回复类型:1-精准回复,2-推荐回复,4-未知回复,10-触发转人工 | |
| └ansContent | object | 机器人回复内容,需按 ansType 解析 | |
| └msgEvaluation | object | ||
| └evaluation | int32 | 是否显示评价:0-不显示评价,1-显示评价 | |
| └evaluationReason | int32 | 是否可填写评价原因:0-不填写,1-可填写 | |
| └evaluationGuide | string | 消息评价引导语 | |
| total | int32 | 分页总数,分页接口返回 | 100 |
| requestId | string | 链路请求 ID | 0a1b2c3d4e5f |
| result | object | 部分历史接口使用 result 字段承载业务数据 |
错误码
| 状态码 | 描述 |
|---|---|
| 14001 | AppKey 缺失或不存在 |
| 14002 | checksum 校验失败 |
| 14003 | 请求时间戳与服务器时间误差超过 10 分钟 |
| 14004 | 请求体不是合法 JSON 对象,或参数缺失、格式非法 |
| 14009 | 频控限制:接口调用超过限流阈值 |
| 14500 | 服务内部错误 |
| 14501 | 数据查询范围超出限制 |
| 14515 | 当前 AppKey 无接口或资源访问权限 |
postEndpoint
/openapi/robot/session/chatcurl -X POST "https://qiyukf.com/openapi/robot/session/chat?appKey=1c088a89de51d0af457616605f28390f&time=1511832531&checksum=f570a5eb049eb803b086e45829b07e48" \ -H "Content-Type: application/json" \ -d '{ "msg": { "msgType": "text", "msgBody": { "content": "订单什么时候发货" } }, "uid": "user-001", "productId": "com.example.app", "fromType": "web" }'{
"code": 200,
"data": {},
"message": "success"
}{
"code": 14001,
"message": "AppKey not exists"
}{
"code": 14002,
"message": "Bad checksum"
}{
"code": 14003,
"message": "Bad time"
}{
"code": 14004,
"message": "body内容json解析错误"
}{
"code": 14009,
"message": "单位时间内请求过于频繁"
}{
"code": 14500,
"message": "Internal error"
}{
"code": 14501,
"message": "Data limit exceeded"
}{
"code": 14515,
"message": "未开通机器人服务"
}这篇文档有帮助吗?