Sending a Message (send)
Scenario
After a customer is connected to an agent, the customer sends channel messages to the agent, including connection, input status, session, transfer-to-manual, and disconnection messages.
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 |
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 |
Description |
---|---|---|---|---|
1 |
reqBody |
Yes |
Request body. |
No. |
Parameter |
Type |
Mandatory |
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. Examples:
|
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. The value is a string of 1 to 24 characters. |
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. The value is the avatar transfer URL of the channel and can contain a maximum of 1024 characters. |
1.12 |
messageId |
String |
No |
Unique ID of the user who sends a 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 passed 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.
{ "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.
{ "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.
{ "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 text message to an agent.
{ "content": "This is a text message.", "controlType": "CHAT", "from": "1678101150955228003", "mediaType": "TEXT", "senderNickname": "user_lk", "sourceType": "CUSTOMER", "timestamp": "1688038541395", "to": "202303061540344336", "userAgent": null, "senderAvatar": null, "channel": "WEB" }
Response parameters
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." }
- Scenario: Send an image message to an agent.
{ "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" }
Response parameters
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." }
- Scenario: Send an audio message to an agent.
{ "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" }
Response parameters
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." }
- Scenario: Send a video message to an agent.
{ "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" }
Response parameters
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." }
- Scenario: Send a file message to an agent.
{ "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" }
Response parameters
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." }
- Scenario: Send a file image message to an agent.
{ "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" }
Response parameters
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." }
- Scenario: Send a file video message to an agent.
{ "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" }
Response parameters
{ "resultCode": "0", "resultDesc": "sendUserMessage successfully." }
- Scenario: Send a web card message to an agent.
{ "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.
{ "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