发送消息 (send)
描述
用户接入座席后,用户侧向座席侧发送渠道消息,包括连接,发送输入状态,会话,转人工,断连多种类型消息
接口方法
POST
接口URI
https://域名/apiaccess/ccmessaging/send,例如域名是https://service.besclouds.com
请求说明
| 序号 | 名称 | 参数类型 | 是否必选 | 说明 |
|---|---|---|---|---|
| 1 | ccmessaging-token | string | True | applyToken接口生成的ccmessaging-token |
| 2 | x-app-key | string | True | appKey字段,用户标识,在ApiFabric工具上配置 |
| 3 | Authorization | string | True | 鉴权字段,内容格式为: Bearer +tokenByAKSK接口的返回值中AccessToken(Bearer后有空格) |
| 序号 | 名称 | 参数类型 | 是否必选 | 说明 |
|---|---|---|---|---|
| 1 | reqBody | True | 请求体 |
| 序号 | 名称 | 参数类型 | 是否必选 | 说明 |
|---|---|---|---|---|
| 1.1 | channel | string | True | 客户端发送消息的所属渠道类型,如WEB(WEB客服接入渠道) |
| 1.2 | content | string | False | 消息内容,视mediaType而定,例如:
|
| 1.3 | controlType | string | True | 消息控制类型,如连接(CONNECT),聊天(CHAT),转人工(TRANS2AGENT),用户输入中(INPUT),断开连接(DISCONNECT),已读(READ) |
| 1.4 | from | string | True | 渠道下发送消息的用户ID,取值范围:1到24位字符串。 |
| 1.5 | mediaType | string | True | 消息媒体类型,如文本类型(TEXT),图片类型(IMAGE),音频类型(AUDIO),视频类型(VIDEO),文件类型(FILE),文件图片(FILE_IMAGE),文件视频(FILE_VIDEO),网页卡片消息(WEBCARD) |
| 1.6 | senderNickname | string | False | 消息发送者的昵称 |
| 1.7 | sourceType | string | True | 消息来源类型,需配置为:CUSTOMER |
| 1.8 | timestamp | string | False | 消息发送时间 |
| 1.9 | to | string | True | 渠道配置ID |
| 1.10 | userAgent | string | False | 用户客户端类型,取自UserAgent |
| 1.11 | senderAvatar | string | False | 消息发送者的头像,渠道传输头像URL,最长1024字符 |
| 1.12 | messageId | string | False | 用户消息唯一编码。最大长度为32。值不能包含逗号“,”。 |
| 1.13 | transData | string | False | json格式数据,连接机器人的时候传给机器人流程。 |
响应说明
- 响应状态码: 200
- 响应状态码: 400
错误的请求:请检查请求路径及参数。
- 响应状态码: 401
未授权:1.请确认是否购买了相关服务。2.请联系客服人员检查您账号的当前状态。
- 响应状态码: 404
请求的内容未找到:请检查请求的路径。
- 响应状态码: 500
业务失败:请依次确认您请求中各参数的取值。
错误码
无。
报文样例
- 场景描述:连接机器人
{ "content": "", "controlType": "CONNECT", "from": "session_1619573111751_user_1619573111751", "mediaType": "TEXT", "senderNickname": "user_1619573111751", "sourceType": "CUSTOMER", "timestamp": "1619573122352", "to": "1011577355744904195", "userAgent": null, "senderAvatar": null, "channel": "WEB" }响应参数:
{ "resultCode": "0", "resultDesc": "connect to robot successfully." }
- 场景描述:与机器人交谈请求
{ "content": "版本", "controlType": "CHAT", "from": "session_1619573111751_user_1619573111751", "mediaType": "TEXT", "senderNickname": "user_1619573111751", "sourceType": "CUSTOMER", "timestamp": "1619573123199", "to": "1011577355744904195", "userAgent": null, "senderAvatar": null, "channel": "WEB" }响应参数:
{ "resultCode": "0", "resultDesc": "Send message to robot successfully" }
- 场景描述:机器人转人工请求
{ "content": "", "controlType": "TRANS2AGENT", "from": "session_1619573111751_user_1619573111751", "mediaType": "TEXT", "senderNickname": "user_1619573111751", "sourceType": "CUSTOMER", "timestamp": "1619573129953", "to": "1011577355744904195", "userAgent": null, "senderAvatar": null, "channel": "WEB" }响应参数:
{ "resultCode": "0", "resultDesc": "transfer from robot to agent success." }
- 场景:向座席发送文本消息
{ "content": "这是一条文字消息", "controlType": "CHAT", "from": "1678101150955228003", "mediaType": "TEXT", "senderNickname": "user_lk", "sourceType": "CUSTOMER", "timestamp": "1688038541395", "to": "202303061540344336", "userAgent": null, "senderAvatar": null, "channel": "WEB" }响应参数
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." } - 场景:向座席发送图片消息
{ "content": "e31d0e44e82f", "controlType": "CHAT", "from": "lk_line_05", "mediaType": "IMAGE", "senderNickname": "lk_line_05", "sourceType": "CUSTOMER", "timestamp": "1688038541395", "to": "202303061540640554", "userAgent": null, "senderAvatar": null, "channel": "LINE" }响应参数:
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." } - 场景:向座席发送音频消息
{ "content": "157831a24986", "controlType": "CHAT", "from": "lk_line_05", "mediaType": "AUDIO", "senderNickname": "lk_line_05", "sourceType": "CUSTOMER", "timestamp": "1688038541395", "to": "202303061540640554", "userAgent": null, "senderAvatar": null, "channel": "LINE" }响应参数:
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." } - 场景:向座席发送视频消息
{ "content": "765c360ab724", "controlType": "CHAT", "from": "lk_line_05", "mediaType": "VIDEO", "senderNickname": "lk_line_05", "sourceType": "CUSTOMER", "timestamp": "1688038541395", "to": "202303061540640554", "userAgent": null, "senderAvatar": null, "channel": "LINE" }响应参数:
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." } - 场景:向座席发送文件消息
{ "content": "test_txt.txt,6,7d9fbcdd-e306-4b84-9831-163fb760cca9,txt", "controlType": "CHAT", "from": "1678101150955228003", "mediaType": "FILE", "senderNickname": "user_lk", "sourceType": "CUSTOMER", "timestamp": "1688038541395", "to": "202303061540344336", "userAgent": null, "senderAvatar": null, "channel": "WEB" }响应参数:
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." } - 场景:向座席发送文件图片消息
{ "content": "70d46bb7-2272-43b7-acad-c6f893a79848,png", "controlType": "CHAT", "from": "1678101150955228003", "mediaType": "FILE_IMAGE", "senderNickname": "user_lk", "sourceType": "CUSTOMER", "timestamp": "1688038541395", "to": "202303061540344336", "userAgent": null, "senderAvatar": null, "channel": "WEB" }响应参数:
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." } - 场景:向座席发送文件视频消息
{ "content": "0471a58b-0323-4b94-bc90-55ff36344471,mp4", "controlType": "CHAT", "from": "1678101150955228003", "mediaType": "FILE_VIDEO", "senderNickname": "user_lk", "sourceType": "CUSTOMER", "timestamp": "1688038541395", "to": "202303061540344336", "userAgent": null, "senderAvatar": null, "channel": "WEB" }响应参数:
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." } - 场景描述:向座席发送网页卡片消息
{ "content": "{\"title\":\"测试title 测试title 测试title\",\"description\":\"测试描述 测试描述 测试描述 测试描述\",\"mediaFileId\":\"xxxx-xxxx-xxxx-xxxx-2e171ac78313\",\"mediaFileType\":\"img\",\"redirectUrl\":\"https://www.****.com\"}", "controlType": "CHAT", "from": "session_1619573111751_user_1619573111751", "mediaType": "WEBCARD", "senderNickname": "user_1619573111751", "sourceType": "CUSTOMER", "timestamp": "1619573129953", "to": "1011577355744904195", "userAgent": null, "senderAvatar": null, "channel": "WEB" }响应参数:{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." } 或 { "resultCode": "3", "resultDesc": "The redirection address is not in the trust list, contact operation staff to add it." } - 场景描述:断连请求
{ "content": "", "controlType": "DISCONNECT", "from": "session_1619573842490_user_1619573842490", "mediaType": "TEXT", "senderNickname": "user_1619573842490", "sourceType": "CUSTOMER", "timestamp": "1619573854156", "to": "1011577355744904195", "userAgent": null, "senderAvatar": null, "channel": "WEB" }响应参数:
{ "resultCode": "0", "resultDesc": "Disconnect robot successfully" }