发送消息 (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
表4 senMsgRsp参数结构 序号
名称
参数类型
说明
1.1
resultDesc
string
返回结果码描述
根据不同的场景,返回描述不一样:
- CONNECT连接座席
如果resultCode返回0:成功
如果resultCode返回11:Queuing...
如果resultCode返回12:The current time is not within the working time of the service agents
如果resultCode返回13:No ccucs address available!或connect failed, none channel config found.
其他非零错误请参见《CCUCS接口开发指南》中的错误码参考。
- CONNECT连接机器人
如果resultCode返回0:connect to robot successfully或process robot multi message successfully。
如果resultCode返回11:Queuing...
如果resultCode返回13:Failed to disconnect robot或No ccucs address available!或fail to initialize robot.或connect failed, none channel config found.
- DISCONNECT断连座席
如果resultCode返回0:disconnect successfully
如果resultCode返回11:Queuing...
如果resultCode返回13:disconnect failed.或disconnect failed, none channel config found.或disconnect failed, session keep touch failed.
- DISCONNECT断连机器人
如果resultCode返回0:Disconnect robot successfully
如果resultCode返回11:Queuing...
如果resultCode返回13:Failed to disconnect robot.或disconnect failed, none channel config found.或disconnect failed, session keep touch failed.
- CHAT座席场景
如果resultCode返回0:sendUserMessage successfully.
如果resultCode返回3:Incorrect JSON format或content can not be empty或the content Json String must contains mediaFileId or redirectUrl或the content Json String must contains title或Incorrect mediaFileType.
如果resultCode返回11:Queuing...
如果resultCode返回13:sendUserMessage failed.或Chat failed because the content is empty.或chat failed, none channel config found.或chat failed, send too quick or session keep touch failed.
- CHAT机器人场景
如果resultCode返回0:Failed to disconnect robot 或Send message to robot successfully 或process robot multi message successfully
如果resultCode返回3:Incorrect JSON format或content can not be empty或the content Json String must contains mediaFileId or redirectUrl或the content Json String must contains title或Incorrect mediaFileType
如果resultCode返回11:Queuing...
如果resultCode返回13:connect failed或Chat failed because the content is empty.或chat failed, none channel config found.或chat failed, send too quick or session keep touch failed.
- TRANS2AGENT场景
如果resultCode返回13:转人工失败,找不到渠道配置transfer to agent failed, none channel config found.
如果resultCode返回13:转人工失败,会话已失效。fail to transfer from robot to agent,session keep touch failed.
如果resultCode返回13:转人工失败,当前已经是人工服务。fail to transfer from robot to agent,it has been agent service.
如果resultCode返回11:Queuing...
如果resultCode返回12:当前非座席工作时间!The current time is not within the working time of the service agents.
如果resultCode返回13:转人工失败, 无法连接CCUCS。fail to transfer from robot to agent,connect to ccucs failed.
如果resultCode返回13:断开机器人连接失败。Failed to disconnect robot.
如果resultCode返回13:当前无可用座席。No agents available currently.
如果resultCode返回0:transfer from robot to agent success.
- INPUT场景
如果resultCode返回0:sendUserMessage successfully.
如果resultCode返回11:Queuing...
如果resultCode返回13:发送输入状态失败,找不到渠道配置。send inputStatus failed, none channel config found.
如果resultCode返回13:现在是机器人服务,此条消息无法发送!This is robot service,this message is prevented!
如果resultCode返回13:发送用户消息失败!sendUserMessage failed
如果resultCode返回13: Queuing...
如果resultCode返回3:发送网页卡片消息成功,但是跳转地址未添加到白名单,座席无法跳转。
The redirection address is not in the trust list, contact operation staff to add it.
1.2
resultCode
string
接口返回码,成功为0,非0失败
1.3
offlineMsg
object
如果离线开关打开,则该值将为true。如果离线开关关闭,AICC将不会返回此对象。
1.3.1
isOfflineStatus
boolean
用于客户端判断连接失败后用户是否可以发送消息。
在以下场景中,
1.用户发送失败(controlType=CONNECT),
2.用户发送(controlType=CHAT)失败,没有会话,
3.用户在技能队列中等待时发送(controlType=DISCONNECT)
1.3.2
tipText
string
当isOfflineStatus为true时,即触发离线模式,消息将被保存。
- CONNECT连接座席
- 响应状态码: 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" }