Sending a Message (send)
Scenario
This interface is invoked to send a channel message (such as a connection, sending input status, session, transfer-to-manual, or disconnection message).
Method
POST
URI
https://Domain name/apiaccess/ccmessaging/send (For example, the domain name is https://service.besclouds.com.)
Request Description
No. |
Parameter |
Type |
Mandatory or Not |
Description |
---|---|---|---|---|
1 |
ccmessaging-token |
String |
Yes |
Value of ccmessaging-token generated by the applyToken interface |
2 |
x-app-key |
String |
Yes |
App key, which is the user ID and is configured on the API Fabric |
3 |
Authorization |
String |
Yes |
Authentication field. The format is Bearer {Value of AccessToken returned by the tokenByAkSk interface}. (A space is required after Bearer.) |
No. |
Parameter |
Type |
Mandatory or Not |
Description |
---|---|---|---|---|
1 |
reqBody |
Yes |
Request body |
No. |
Parameter |
Type |
Mandatory or Not |
Description |
---|---|---|---|---|
1.1 |
channel |
String |
Yes |
Type of the channel through which the client sends a message, for example, the web channel (web customer service access channel) |
1.2 |
content |
String |
No |
Message content, which varies depending on mediaType. For example, if mediaType is set to TEXT, the value is the text content to be sent. The size of the text content to be sent cannot exceed 1 KB. If mediaType is set to audio, video, or other media types, the value is in the format of fileId,mediaType, where fileId indicates the value of objectKey returned by the /ccmessaging/uploadFileStream interface. The value is value of objectKey,jpg for images, value of objectKey,mp4 for videos, value of objectKey,mp3 for audio, and value of objectKey,txt for locations. The file download interface uses fileId to download a file. If mediaType is set to WEBCARD, the value is a string converted from the JSON structure. For example, the fixed JSON structure is as follows: {"title":"Card title","description":"Card description","mediaFileId":"Card media file ID (which is returned by the upload interface)","mediaFileType":"Only fixed values img, img/png, and img/jpg are supported. If this parameter is left empty, the default value jpg is used.","redirectUrl":"Redirection URL"} Either redirectUrl or mediaFileId must be set. Other parameters can be left empty. For details, see the example of sending a web card message to an agent. |
1.3 |
controlType |
String |
Yes |
Message control type. The options are CONNECT, CHAT, TRANS2AGENT, INPUT, DISCONNECT, and READ. |
1.4 |
from |
String |
Yes |
ID of the user who sends a message through a channel |
1.5 |
mediaType |
String |
Yes |
Message media type. The options are TEXT, IMAGE, AUDIO, VIDEO, FILE, FILE_IMAGE, FILE_VIDEO, WEBCARD, and LOCATE. |
1.6 |
senderNickname |
String |
No |
Nickname of the message sender |
1.7 |
sourceType |
String |
Yes |
Message source type. Set this parameter to CUSTOMER. |
1.8 |
timestamp |
String |
No |
Time when a message is sent |
1.9 |
to |
String |
Yes |
Channel configuration ID |
1.10 |
userAgent |
String |
No |
User client type, which is obtained from UserAgent |
1.11 |
senderAvatar |
String |
No |
Avatar of the message sender. For the WeChat channel, the WeChat avatar URL is transmitted. |
1.12 |
messageId |
String |
No |
Unique ID of the user who sends the message. The value can contain a maximum of 32 characters. The value cannot contain commas (,). |
1.13 |
transData |
String |
No |
Data in JSON format, which is transferred to the robot flow when the robot is connected |
Response Description
- Status code: 200
- Status code: 400
Incorrect request. Check the request path and parameters.
- Status code: 401
Unauthorized operation. 1. Check whether you have purchased related services. 2. Contact customer service to check the status of your account.
- Status code: 404
The requested content is not found. Check the request path.
- Status code: 500
Business failure. Check the values of parameters in the request.
Error Codes
None
Example
- Scenario: Send a request for connecting to the robot.
Request parameters:
{ "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" }
Response parameters:
{ "resultCode": "0", "resultDesc": "connect to robot successfully." }
- Scenario: Send a request for chatting with a robot.
Request parameters:
{ "content": "Version", "controlType": "CHAT", "from": "session_1619573111751_user_1619573111751", "mediaType": "TEXT", "senderNickname": "user_1619573111751", "sourceType": "CUSTOMER", "timestamp": "1619573123199", "to": "1011577355744904195", "userAgent": null, "senderAvatar": null, "channel": "WEB" }
Response parameters:
{ "resultCode": "0", "resultDesc": "Send message to robot successfully" }
- Scenario: Send a request for switching from robot service to manual service.
Request parameters:
{ "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" }
Response parameters:
{ "resultCode": "0", "resultDesc": "transfer from robot to agent success." }
- Scenario: Send a web card message to an agent.
Request parameters:
{ "content": "{\"title\":\"Test title\",\"description\":\"Test 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" }
Response parameters:
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." } or { "resultCode": "3", "resultDesc": "The redirection address is not in the trust list, contact operation staff to add it." }
- Scenario: Send a disconnection request.
Request parameters:
{ "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" }
Response parameters:
{ "resultCode": "0", "resultDesc": "Disconnect robot successfully" }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot