tencent cloud

Cloud Contact Center

Announcement
What's New
Cloud Contact Center Terminology Update
What is Tencent Cloud Contact Center
Overview
Feature List
Terms Introduction
Handling Firewall Restrictions
AI Voicebot
Billing Guide
Voice Call Billing Overview
Desk Billing Overview
View Billing
Refund Policy
New User Guide
Voice Guide
Desk Guide
Use Case
Inbound: Customer Experience
Outbound: Telemarketing
Auto Dialer: Voice Notification
Integration Use Case (SDK)
Administrator Guide
Voice Guide
Desk Guide
Member Guide
Voice Guide
Desk Guide
AI Voice Agent Guide
Introducing AI Voice Agent
AI Voice Agent Practical Tutorial
Set Up Your AI Voice Agent
Activate AI Voice Agent Call
AI Voice Agent Call Logs
Developer Guide
SDK Development Guide
Data Push
Voice API Reference
History
Introduction
API Category
Making API Requests
Agent APIs
Skill Group APIs
Number APIs
Dual Call APIs
Predictive Outbound Call APIs
SIP Phone APIs
Call Service Record APIs
Billing APIs
Other APIs
Outbound Call APIs
Speech Intelligent Agent APIs
Data Types
Error Codes
Desk API Reference
API Reference
Callback Configuration
FAQs
Data Deletion Guide
Legal
Privacy Policy
Data Processing And Security Agreement
Service Level Agreements
TENCENT CLOUD CONTACT CENTRE TERMS OF USE
Glossary
Contact Us

Send Messages

Mode fokus
Ukuran font
Terakhir diperbarui: 2025-04-07 14:59:27

API Call Description

App admins can send messages to users using this API. After being transferred to live agent, agent can also see all previous messages.
This API is applicable to the following two scenarios:
1. Send message by the SessionId of the specified session. This scenario is applicable for the integration methods of all user ends, including web pages (H5), applications/clients.
2. Specify the customer service account and the user's UserID to send messages. This scenario is only applicable to the user-end integration method of "application/client". This interface only supports specifying the customer service account to send messages to users.
Request URL sample:
https://console.tim.qq.com/v4/desk_http_svc/send_msg?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json

Request Parameters

The following table only lists the parameters involved in modification when calling this API and their descriptions. For more details about the parameters, please see REST API Introduction.
Parameter
Description
v4/desk_http_svc/send_msg
Request API.
sdkappid
Assigned SDKAppID in the IM console when creating an application.
identifier
Must be an App administrator account. For more details, see App Administrator.
usersig
Signature generated by the App administrator account. For specific operations, see Generate UserSig.
random
Enter a random 32-bit unsigned integer in the range of [0,4294967295].
contenttype
The request format is fixed as json.

Sample Request Packet

Send message to a session using its session ID.

{
"SessionId": "fd8a2e30-54de-4e40-bcaf-02718409c5cf",
"MsgRandom": 8436874,
"MsgBody": [
{
"MsgType": "TIMTextElem",
"MsgContent": {
"Text": "Welcome to use smart customer service. Glad to serve you."
}
}
],
"CloudCustomData": "your cloud custom data"
}

Send text message to a target using the customer service account and userID (applicable only to "app/client" integration).

{
"FromAccount": "@customer_service_account",
"ToAccount": "user45",
"MsgRandom": 82139,
"MsgBody": [
{
"MsgType": "TIMTextElem",
"MsgContent": {
"Text": "Welcome to register with xx mall. You can purchase the products you want herein. If you have any questions, contact our customer service."
}
}
],
"CloudCustomData": "your cloud custom data"
}

Sending Custom Messages Via Cards

The Data field of the custom message can refer to the description of Card Message. Other custom message formats defined by smart customer service can be found in UI Client Integration. Serialize the JSON data structure defined in this document and place it in the Data field.
{
"FromAccount": "@customer_service_account",
"ToAccount": "user45",
"MsgRandom": 82139,
"MsgBody": [
{
"MsgType": "TIMCustomElem",
"MsgContent": {
"Data": "{\\"src\\": \\"22\\",\\"content\\": {\\"header\\": \\"card title\\",\\"desc\\": \\"description\\",\\"pic\\": \\"https://static.cloudcachetci.com/qcloud/portal/kit/images/presale.a4955999.jpeg\\",\\"url\\": \\"https://www.qcloud.com/\\"},\\"customerServicePlugin\\": 0}"
}
}
],
"CloudCustomData": "your cloud custom data"
}

Request Packet Fields

Field
Type
Required
Description
SessionId
String
Optional.
Session ID. If this field is filled, there is no need to fill the FromAccount and ToAccount fields.
FromAccount
String
Optional.
Sender UserID, applicable only to the client-side integration method of "application/client", and the sender must be a customer service account.
ToAccount
String
Optional.
Recipient UserID, applicable only to the client-side integration method of "application/client", and the recipient is a general user.
MsgRandom
Integer
Required
Message random number (a 32-bit unsigned integer) for deduplication.
MsgBody
Array
Required
Message content, for the specific format, please see message format description. For the custom message formats defined by smart customer service (such as card messages, order messages, etc.), please participate Integration Solution (No UI). Serialize the well-defined JSON data structure in the document and place it into the Data field of the custom message.
CloudCustomData
String
Optional.
Custom message data. For details, please refer to CloudCustomData.
ExcludeFromUserRespTimeout
Integer
Optional.
Control whether this message is counted into the countdown of "user reply timeout" when a user chats with a human customer service. 0 means timing, and 1 means no timing. The default is 0.

Response Package Example

{
"ActionStatus": "OK",
"ErrorInfo": "",
"ErrorCode": 0
}

Response Packet Fields

Field
Type
Description
ErrorCode
Integer
Error Code:
0 indicates success.
Non-zero indicates failure.
ErrorInfo
String
Error message.
ActionStatus
String
Result of request processing.

Error Code Description

Unless network error (for example, 502 error) occurs, the HTTP return code of this API is always 200. The actual error code and error information are represented by ErrorCode and ErrorInfo in the response packet body. For common error codes (60000 to 79999), see Error Code document. The private error codes of this API are as follows:
Error Code
Description
90001
JSON format parsing failed. Check whether the request package conforms to the JSON Specification.
90002
The MsgBody in the JSON format request packet does not match the message format description, or the MsgBody is not an Array type. Please see the definition of TIMMsgElement object.
90005
The JSON format request body lacks the MsgRandom field or the MsgRandom field is not of Integer type.
90007
The MsgBody in the JSON format request body is not of Array type. Change it to Array type.
90009
Request requires App administrator permissions.
90010
The JSON format request packet does not match the message format description. Please see the definition of TIMMsgElement object.
93000
The JSON data packet is overly long. The message body should not exceed 12K.
141002
Internal error, retry.
141004
Invalid parameter.
141005
The session does not exist or has stopped.

API Debugging Tool

Debug this interface using the REST API online debugging tool.

References

Query one-to-one chat messages (v4/openim/admin_getroammsg)

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan