Starter Deal! First 3 month from only  $9.9 /month!
Starter Deal! First 3 month from only  $9.9 /month!
Grab It Now 
Chat
  • Web
    • TUIKit
      • Overview
      • Installaton
        • TUIKit
          • Vue
          • React
        • TUIChat Only
          • Vue
      • Features
        • Reactions
        • Read Receipt
        • Typing Status
        • User Online Status
      • Themes
        • Setting UI Styles
          • Web
          • Mobile
      • Customization
        • Customize Messages
      • Localization
    • SDK
      • Install Chat SDK
      • Initialize Chat SDK
      • Login and Logout
      • Client APIs
      • Message
        • Overview
        • Send a Message
        • Receive a Message
        • Historical Message
        • Forward Messages
        • Modify a Message
        • Delete Messages
        • Clear History Message
        • Recall a Message
        • Send an Online Message
        • Message Read Receipt
        • Query Messages
        • Targeted Group Message
        • Do not Notify
        • Key-Value Extensions
        • Translation
      • Conversation
        • Overview
        • Conversation List
        • Get Conversations
        • Unread Count
        • Pin Conversations
        • Delete Conversations
        • Mark
        • Conversation Group
      • Group
        • Overview
        • Group Management
        • Group Profile
        • Group Member Management
        • Group Member Profile
        • Custom Group Attribute
        • Group Counter
      • Community Topic
        • Community Management
      • User Profile and Relationship Chain
        • User Profile
        • User Status
        • Friend Management
        • Friend List
        • Block List
  • Android
    • Run Demo
    • UIKit
      • Overview
      • Getting Started
      • Installation
        • TUIKit
        • TUIChat Only
      • Features
        • Reactions
        • Read Receipt
        • User Online Status
        • Search Messages
      • Customization
        • Customize Messages
        • Customize Emojis and Stickers
      • Localization
    • SDK
      • Install Chat SDK
      • Initialize Chat SDK
      • Login and Logout
      • Message
        • Overview
        • Send a Message
        • Receive a Message
        • Retrieve Messages
        • Forward Messages
        • Modify a Message
        • Insert a Message
        • Delete Messages
        • Clear History Messages
        • Recall a Message
        • Send an Online Message
        • Message Read Receipt
        • Query Messages
        • Metions
        • Targeted Group Message
        • Do not Notify
        • Key-Value Extensions
        • Reactions
        • Translation
        • Pin Messages
      • Conversation
        • Overview
        • Conversation List
        • Get Conversations
        • Unread Count
        • Pin Conversations
        • Delete Conversations
        • Draft
        • Mark
        • Conversation Group
      • Group
        • Overview
        • Manage Group
        • Profile
        • Manage Members
        • Member Profile
        • Attribute
        • Counter
      • Community and Topic
        • Manage Community
        • Permission Group
      • User
        • User Profile
        • User Status
        • Manage Friends
        • Friend Group
        • Block Lists
      • Local Search
        • Search Messages
        • Search Friends
        • Search Groups
        • Search Group Members
      • Signaling
      • API Reference
        • Java
  • iOS and macOS
    • Run Demo
    • UIKit
      • Overview
      • Getting Started
      • Installation
        • TUIKit
        • TUIChat Only
      • Features
        • Reactions
        • Read Receipt
        • User Online Status
        • Search Messages
      • Customization
        • Customize Messages
        • Customize Emojis and Stickers
      • Localization
    • SDK
      • Installation
        • iOS
        • macOS
      • Initialize Chat SDK
      • Login and Logout
      • Message
        • Overview
        • Send a Message
        • Receive a Message
        • Retrieve Messages
        • Forward Messages
        • Modify a Message
        • Insert a Message
        • Delete Messages
        • Clear History Messages
        • Recall a Message
        • Send an Online Message
        • Message Read Receipt
        • Query Messages
        • Metions
        • Targeted Group Messages
        • Do not Notify
        • Key-Value Extensions
        • Reactions
        • Translation
        • Pin Messages
      • Conversation
        • Overview
        • Conversation List
        • Get Conversations
        • Unread Count
        • Pin Conversations
        • Delete Conversations
        • Draft
        • Mark
        • Conversation Group
      • Group
        • Overview
        • Manage Group
        • Profile
        • Manage Members
        • Member Profile
        • Attribute
        • Counter
      • Community and Topic
        • Manage Community
        • Permission Group
      • User
        • User Profile
        • User Status
        • Manage Friends
        • Friend Group
        • Block Lists
      • Local Search
        • Search Messages
        • Search Friends
        • Search Groups
        • Search Group Members
      • Signaling
      • API Reference
        • Swift
        • Objective-C
  • Windows
    • SDK
      • Install Chat SDK
      • Initialize Chat SDK
      • Login and Logout
      • Message
        • Overview
        • Send a Message
        • Receive a Message
        • Retrieve Messages
        • Forward Messages
        • Modify a Message
        • Insert a Message
        • Delete Messages
        • Clear History Messages
        • Recall a Message
        • Send an Online Message
        • Message Read Receipt
        • Query Messages
        • Metions
        • Targeted Group Messages
        • Do not Notify
        • Key-Value Extensions
        • Reactions
        • Translation
        • Pin Messages
      • Conversation
        • Overview
        • Conversation List
        • Get Conversations
        • Unread Count
        • Pin Conversations
        • Delete Conversations
        • Draft
        • Mark
        • Conversation Group
      • Group
        • Overview
        • Manage Group
        • Profile
        • Manage Members
        • Member Profile
        • Attribute
        • Counter
      • Community and Topic
        • Manage Community
        • Permission Group
      • User
        • User Profile
        • User Status
        • Manage Friends
        • Friend Group
        • Block Lists
      • Local Search
        • Search Messages
        • Search Friends
        • Search Groups
        • Search Group Members
      • Signaling
      • API Reference
        • C++
        • C
  • Flutter
    • Run Demo
    • UIKIT
      • Overview
      • Installation
        • integrated
      • Features
        • Local Search
        • Offline Push
        • Online Status
        • Typing Status
        • Message Read Receipt
        • Message Reactions
        • Internationalization
        • Adding Custom Messages
        • Emoji & Stickers
      • Customization
        • Modifying UI Themes
        • Setting UI Styles
    • SDK
      • Install Chat SDK
        • Install
      • Initialize Chat SDK
        • Initialize
      • Login And Logout
        • Login and Logout
      • Message
        • Message Overview
        • Sending Message
        • Receiving Message
        • Historical Message
        • Forwarding Message
        • Modifying Message
        • Message Inserting
        • Deleting Message
        • Clearing Messages
        • Recalling Message
        • Online Message
        • Read Receipt
        • Querying Message
        • Group @ Message
        • Targeted Group Message
        • Notification Muting
        • Message Extension
      • Conversation
        • Conversation Overview
        • Conversation List
        • Getting Conversation
        • Conversation Unread Count
        • Pinning Conversation to the Top
        • Deleting Conversation
        • Conversation Draft
        • Conversation Group
      • Group
        • Group Overview
        • Group Management
        • Group Profile
        • Group Member Management
        • Group Member Profile
        • Custom Group Attribute
      • User
        • User Profile
        • Friend Management
        • Friend List
        • Blocklist
      • Offline Push
        • Offline Push
      • Signaling
        • Signaling Management
      • Local Search
        • Searching for Message
        • Searching for Friend
        • Searching Group
        • Searching for Group Member
      • API Reference
        • Client APIs
  • React Native
    • Run Demo
    • SDK
      • SDK Integration
      • Initialization
      • Login and Logout
      • Message
        • Message Overview
        • Sending Message
        • Receiving Message
        • Historical Message
        • Forwarding Message
        • Modifying Message
        • Message Inserting
        • Deleting Message
        • Clearing Messages
        • Recalling Message
        • Online Message
        • Read Receipt
        • Querying Message
        • Group @ Message
        • Targeted Group Message
        • Notification Muting
        • Message Extension
      • Group
        • Overview
        • Group Management
        • Group Profile
        • Group Member Management
        • Group Member Profile
        • Custom Group Attribute
        • Community Management
      • User
        • User Profile
        • Friend Management
        • Friend List
        • Blocklist
      • Offline Push
        • Offline Push
      • Local Search
        • Searching for Message
        • Searching for Friend
        • Searching Group
        • Searching for Group Member
      • Signaling
        • Signaling Management
  • Unity(Game Solution)
    • Run Demo
    • SDK
      • SDK Integration
      • Initialization
      • Login and Logout
      • Message
        • Message Overview
        • Sending Message
        • Receiving Message
        • Historical Message
        • Forwarding Message
        • Modifying Message
        • Deleting Message
        • Clearing Messages
        • Recalling Message
        • Online Message
        • Read Receipt
        • Querying Message
        • Group @ Message
        • Targeted Group Message
        • Notification Muting
        • Message Extension
      • Conversation
        • Conversation Overview
        • Conversation List
        • Getting Conversation
        • Conversation Unread Count
        • Pinning Conversation to the Top
        • Deleting Conversation
        • Conversation Draft
        • Conversation Mark
        • Conversation Group
      • Group
        • Group Overview
        • Group Management
        • Group Profile
        • Group Member Management
        • Group Member Profile
        • Custom Group Attribute
        • Group Counter
      • User
        • User Profile
        • User Status
        • Friend Management
        • Friend List
        • Blocklist
  • Unreal Engine(Game Solution)
    • SDK
      • SDK Integration
  • Free Demos
  • Server APIs
    • Generating UserSig
    • RESTful APIs
      • RESTful API Overview
      • RESTful API List
      • Message Related
        • Send Message
          • Sending One-to-One Messages to One User
          • Sending One-to-One Messages to Multiple Users
          • Sending Ordinary Messages in a Group
          • Sending System Messages in a Group
          • Broadcast Message of Audio-Video Group
          • Importing One-to-One Messages
          • Importing Group Messages
        • Historical Message
          • Modifying Historical One-to-one Messages
          • Modifying Historical Group Messages
          • Pulling Historical One-to-one Messages
          • Pulling Historical Group Messages
        • Delete Message
          • Deleting Messages Sent by a Specified User
        • Withdraw Message
          • Recalling One-to-One Messages
          • Recalling Group Messages
        • Read Receipt
          • Marking One-to-One Messages as Read
          • Pulling Group Message Read Receipt Details
          • Pulling Read Receipts for Group Messages
        • Message Extension
          • Pulling the Message Extension of a One-to-One Message
          • Configuring Message Extension for a One-to-One Message
          • Pulling Message Extension of a Group Message
          • Configuring Message Extension for a Group Message
        • Pushing to All Users
          • API for Pushing to All Users
          • Pushing to All Users
          • Setting Application Attribute Names
          • Getting Application Attribute Names
          • Getting User Attributes
          • Setting User Attributes
          • Deleting User Attributes
          • Getting User Tags
          • Adding User Tags
          • Deleting User Tags
          • Deleting All Tags of a User
      • Session Related
        • Conversation List
          • Pulling a conversation list
        • Session Unread Count
          • Setting the Unread Message Count of a Member
          • Querying Unread One-to-One Message Count
        • Delete Session
          • Deleting a conversation
        • Session Grouping Tag
          • Creating Conversation Group Data
          • Updating Conversation Group Data
          • Deleting Conversation Group Data
          • Creating or Updating Conversation Mark Data
          • Searching for Conversation Group Marks
          • Pulling Conversation Group Mark Data
      • Group Related
        • Group Management
          • Getting All Groups in an App
          • Creating a Group
          • Disbanding a Group
          • Getting the Groups a User Has Joined
        • Group Information
          • Getting Group Profiles
          • Modifying the Profile of a Group
          • Importing a Group Profile
        • Group Member Management
          • Adding Group Members
          • Deleting Group Members
          • Banning Group Members
          • Unbanning Group Members
          • Bulk Muting and Unmuting
          • Getting the List of Muted Group Members
          • Changing Group Owner
          • Querying the Roles of Users in a Group
          • Importing Group Members
        • Group Member Information
          • Getting Group Member Profiles
          • Modifying the Profile of a Group Member
        • Group Custom Attributes
          • Getting Group Custom Attributes
          • Modifying Group Custom Attributes
          • Clearing Group Custom Attributes
          • Resetting Group Custom Attributes
          • Deleting Group Custom Attributes
        • Live Group Management
          • Getting the Number of Online Users in an Audio-Video Group
          • Getting the List of Online Members in Audio-Video Group
          • Setting Audio-Video Group Member Marks
          • Getting the List of Banned Group Members.
        • Community Management
          • Creating Topic
          • Deleting Topic
          • Getting Topic Profile
          • Modifying Topic Profile
          • Importing Topic Profiles
        • Group Counter
          • Getting Group Counters
          • Updating Group Counters
          • Deleting Group Counters
      • User Management
        • Account Management
          • Importing a Single Account
          • Importing Multiple Accounts
          • Deleting Accounts
          • Querying Accounts
        • User Information
          • Setting Profiles
          • Pulling Profiles
        • User Status
          • Invalidating Account Login States
          • Querying Account Online Status
        • Friend Management
          • Adding Friends
          • Importing Friends
          • Updating Friends
          • Deleting Friends
          • Deleting All Friends
          • Verifying Friends
          • Pulling Friends
          • Pulling Specified Friends
        • Friend Lists
          • Adding Lists
          • Deleting Lists
          • Pulling Lists
        • Blocklist
          • Blocklisting Users
          • Unblocklisting Users
          • Pulling a Blacklist
          • Verifying Users on a Blocklist
      • Global Mute Management
        • Setting Global Mute
        • Querying Global Mute
      • Operations Management
        • Pulling Operations Data
        • Downloading Recent Messages
        • Getting Server IP Addresses
      • Chatbots
        • Pulling Chatbot Accounts
        • Creating Chatbot Accounts
        • Deleting Chatbot Accounts
    • Webhooks
      • Webhook Overview
      • Webhook Command List
      • Operations Management Callbacks
        • API Overclocking Alarm Callbacks
      • Online Status Webhooks
        • Status Change Webhooks
      • Relationship Chain Webhooks
        • After a Profile Is Updated
        • Before a Friend Is Added
        • Before a Friend Request Is Responded
        • After a Friend Is Added
        • After a Friend Is Deleted
        • After a User Is Added to Blocklist
        • After a User Is Removed from Blocklist
      • One-to-One Message Webhooks
        • Before a One-to-One Message Is Sent
        • After a One-to-One Message Is Sent
        • After a One-to-One message Is Marked as Read
        • After A One-to-One Message Is Recalled
      • Group Webhooks
        • Before a Group Is Created
        • After a Group Is Created
        • Before Applying to Join a Group
        • Before Inviting a User to a Group
        • After a User Joins a Group
        • After a User Leaves a Group
        • Before Group Message Is Sent
        • After a Group Message Is Sent
        • After a Group Is Full
        • After a Group Is Disbanded
        • After Group Profile Is Modified
        • Callback After Recalling Group Messages
        • Webhook for Online and Offline Status of Audio-Video Group Members
        • Webhook for Exceptions When Group Messages Are Sent
        • Before a Topic Is Created
        • After a Topic Is Created
        • After a Topic Is Deleted
        • Topic Profile Change Webhook
        • Callback After Group Member Profile Changed
        • Callback After Group Attribute Changed
        • Callback After Read Receipt
        • Callback After the Group Owner Changed
      • Webhook Mutual Authentication Configuration Guide
        • Apache Mutual Authentication Configuration
        • Nginx Mutual Authentication Configuration
      • Chatbot webhooks
        • Chatbot Passthrough Message Callback
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes
Chat

Send a Message

Creating a Message

Creating a text message

This API is used to create a text message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send a text message.
API
chat.createTextMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
userID or groupID of the message receiver
conversationType
String
-
Conversation type. Valid values:
TencentCloudChat.TYPES.CONV_C2C (one-to-one conversation)
TencentCloudChat.TYPES.CONV_GROUP (group conversation)
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled. This attribute is supported by v2.10.2 or later
receiverList
Array | undefined

The list of group members who can receive targeted messages (not applicable to Community group and Audio-video group)
isSupportExtension
Boolean
false
Whether message extensions are supported: true (supported) or false (not supported) (requires you to purchase the flagship package)
The payload is as described below:
Name
Type
Description
text
String
Message text content
Returned value
Message
Sample
// 1. Create a message instance. The returned instance can be displayed on the screen.
let message = chat.createTextMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
// priority: TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL,
payload: {
text: 'Hello world!'
},
// To use the read receipt feature, you need to purchase the Premium edition
// and set `needReadReceipt` to `true` when creating a message.
needReadReceipt: true
// cloudCustomData: 'your cloud custom data'
});
// 2. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});

Creating an @ message

This API is used to create an @ text message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send a text message.
Note
1. It applies only to group chats, and @all members is not supported for a community and its topic.
API
chat.createTextAtMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
userID or groupID of the message receiver
conversationType
String
-
Conversation type. Valid values:
TencentCloudChat.TYPES.CONV_GROUP (group conversation)
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled.
The payload is as described below:
Name
Type
Description
text
String
Text content
atUserList
Array
List of users that need to be mentioned (@). To mention (@) all, pass in TencentCloudChat.TYPES.MSG_AT_ALL. For example, to mention (@) denny and lucy as well as all members, pass in ['denny', 'lucy', TencentCloudChat.TYPES.MSG_AT_ALL] for atUserList.
Returned value
Sample
// 1. Create a message instance. The returned instance can be displayed on the screen.
let message = chat.createTextAtMessage({
to: 'group1',
conversationType: TencentCloudChat.TYPES.CONV_GROUP,
// priority: TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL,
payload: {
text: '@denny @lucy @all Dinner tonight. Reply 1 if you receive this message',
// 'denny' and 'lucy' are `userID` values, not nicknames
atUserList: ['denny', 'lucy', TencentCloudChat.TYPES.MSG_AT_ALL]
},
// cloudCustomData: 'your cloud custom data'
});
// 2. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});

Creating an image message

This API is used to create an image message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send an image message.
API
chat.createImageMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
Message receiver
conversationType
String
-
Conversation type. Valid values: TencentCloudChat.TYPES.CONV_C2C, TencentCloudChat.TYPES.CONV_GROUP.
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
onProgress
function
-
Callback function for getting the upload progress
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled.
The payload is as described below:
Name
Type
Description
file
HTMLInputElement | Object
It is used to select a DOM node (web) or File object (web) of the image. The SDK reads the data contained in this parameter and uploads the image.
Returned value
Message
Sample
// Sample 1: Sending an image message on web - passing in a DOM node
// 1. Create a message instance. The returned instance can be displayed on the screen.
let message = chat.createImageMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
// priority: TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL,
payload: {
file: document.getElementById('imagePicker'),
},
// cloudCustomData: 'your cloud custom data'
onProgress: function(event) { console.log('file uploading:', event) }
});

// 2. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});
// Sample 2: Sending an image message on web - passing in a File object
// Add a message input box with the ID set to `testPasteInput`
document.getElementById('testPasteInput').addEventListener('paste', function(e) {
let clipboardData = e.clipboardData;
let file;
let fileCopy;
if (clipboardData && clipboardData.files && clipboardData.files.length > 0) {
file = clipboardData.files[0];
// After the image message is sent successfully
// the content pointed to by `file` may be cleared by the browser.
// If you have extra rendering needs, you can copy the data in advance.
fileCopy = file.slice();
}

if (typeof file === 'undefined') {
console.warn('The `file` is `undefined`. Check for the compatibility of the code or browser.');
return;
}

// 1. Create a message instance. The returned instance can be displayed on the screen.
let message = chat.createImageMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
payload: {
file: file
},
onProgress: function(event) { console.log('file uploading:', event) }
});

// 2. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});
});

Creating an audio message

This API is used to create an audio message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send an audio message.
API
chat.createAudioMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
Message receiver
conversationType
String
-
Conversation type. Valid values:
TencentCloudChat.TYPES.CONV_C2C
TencentCloudChat.TYPES.CONV_GROUP
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled.
The payload is as described below:
Name
Type
Description
file
Object
File information obtained after recording
Returned value
Message

Creating a video message

This API is used to create a video message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send a video message.
API
chat.createVideoMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
Message receiver
conversationType
String
-
Conversation type. Valid values:
TencentCloudChat.TYPES.CONV_C2C
TencentCloudChat.TYPES.CONV_GROUP
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled.
The payload is as described below:
Name
Type
Description
file
HTMLInputElement | File | Object
Data field of the custom message
Returned value
Message
Sample
// Sample: Sending a video message on web
// 1. Get the video file by passing in the DOM node.
// 2. Create a message instance.
const message = chat.createVideoMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
payload: {
file: document.getElementById('videoPicker') // Alternatively, use `event.target`
},
onProgress: function(event) { console.log('file uploading:', event) }
});
// 3. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});

Creating a custom message

This API is used to create a custom message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send a custom message. When the current SDK capabilities cannot meet your needs, you can customize messages.
API
chat.createCustomMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
userID or groupID of the message receiver
conversationType
String
-
Conversation type. Valid values:
TencentCloudChat.TYPES.CONV_C2C (one-to-one conversation)
TencentCloudChat.TYPES.CONV_GROUP (group conversation)
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled.
The payload is as described below:
Name
Type
Description
data
String
Data of the custom message
description
String
Description of the custom message
extension
String
Extension of the custom message
Returned value
Message
Sample
// Sample: Using a custom message to implement dice rolling
// 1. Define the random function.
function random(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
// 2. Create a message instance. The returned instance can be displayed on the screen.
let message = chat.createCustomMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
payload: {
data: 'dice', // Used to identify the message as a dice message
description: String(random(1,6)), // Get the outcome
extension: ''
}
});
// 3. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});

Creating an emoji message

This API is used to create an emoji message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send an emoji message.
API
chat.createFaceMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
userID or groupID of the message receiver
conversationType
String
-
Conversation type. Valid values:
TencentCloudChat.TYPES.CONV_C2C (one-to-one conversation)
TencentCloudChat.TYPES.CONV_GROUP (group conversation)
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled.
The payload is as described below:
Name
Type
Description
index
Number
Emoji index, which is customized by the user
data
String
Extra data
Returned value
Message
Sample
// Send an emoji message on web
// 1. Create a message instance. The returned instance can be displayed on the screen.
let message = chat.createFaceMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
payload: {
index: 1, // Number. Emoji index, which is customized by the user
data: 'tt00' // String. Extra data
},
// cloudCustomData: 'your cloud custom data'
});
// 2. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});

Creating a file message

This API is used to create a file message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send a file message.
API
chat.createFileMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
userID or groupID of the message receiver
conversationType
String
-
Conversation type. Valid values:
TencentCloudChat.TYPES.CONV_C2C (client to client conversation)
TencentCloudChat.TYPES.CONV_GROUP (group conversation)
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
onProgress
function
-
Callback function for getting the upload progress
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled.
The payload is as described below:
Name
Type
Description
file
HTMLInputElement | File | Object
It is used to select a DOM node or File object of the file on web, or the success callback parameter of the uni.chooseFile API. The SDK reads the data contained in this parameter and uploads the file.
Returned value
Sample
// Sample 1: Sending a file message on web - passing in a DOM node
// 1. Create a file message instance. The returned instance can be displayed on the screen.
let message = chat.createFileMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
payload: {
file: document.getElementById('filePicker'),
},
// cloudCustomData: 'your cloud custom data'
onProgress: function(event) { console.log('file uploading:', event) }
});

// 2. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});
// Sample 2: Sending a file message on web - passing in a File object
// Add a message input box with the ID set to `testPasteInput`,
let clipboardData = e.clipboardData;
let file;
let fileCopy;
if (clipboardData && clipboardData.files && clipboardData.files.length > 0) {
file = clipboardData.files[0];
// After the image message is sent successfully
// the content pointed to by `file` may be cleared by the browser.
// If you have extra rendering needs, you can copy the data in advance.
fileCopy = file.slice();
}

if (typeof file === 'undefined') {
console.warn('The `file` is `undefined`. Check for the compatibility of the code or browser.');
return;
}

// 1. Create a message instance. The returned instance can be displayed on the screen.
let message = chat.createFileMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
payload: {
file: file
},
onProgress: function(event) { console.log('file uploading:', event) }
});

// 2. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});
});

Creating a geographical location message

This API is used to create a geographical location message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send a geographical location message.
API
chat.createLocationMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
userID or groupID of the message receiver
conversationType
String
-
Conversation type. Valid values:
TencentCloudChat.TYPES.CONV_C2C (one-to-one conversation)
TencentCloudChat.TYPES.CONV_GROUP (group conversation)
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled.
The payload is as described below:
Name
Type
Description
description
String
Description of the geographical location
longitude
Number
Longitude
latitude
Number
Latitude
Returned value
Message
Sample
// Send a geographical location message on web
// 1. Create a message instance. The returned instance can be displayed on the screen.
let message = chat.createLocationMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
payload: {
description: 'Tencent Building, No. 10000, Shennan Boulevard, Shenzhen',
longitude: 113.941079, // Longitude
latitude: 22.546103 // Latitude
}
});
// 2. Send the message.
let promise = chat.sendMessage(message);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});

Creating a merged message

This API is used to create a merged message. It returns a message instance, which can be sent by calling the sendMessage API when you need to send a merged message.
Note
1. This API does not support merging messages that failed to be sent. If the message list contains a message that failed to be sent, the API will report an error.
API
chat.createMergerMessage(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Default
Description
to
String
-
userID or groupID of the message receiver
conversationType
String
-
Conversation type. Valid values:
TencentCloudChat.TYPES.CONV_C2C (one-to-one conversation)
TencentCloudChat.TYPES.CONV_GROUP (group conversation)
priority
String
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL
Message priority. If messages in a group exceed the frequency limit, the backend will deliver high-priority messages first. Supported enumerated values:
TencentCloudChat.TYPES.MSG_PRIORITY_HIGH
TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default)
TencentCloudChat.TYPES.MSG_PRIORITY_LOW
TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST
payload
Object
-
Message content container
cloudCustomData
String
''
Custom message data, which is saved in the cloud, will be sent to the receiver, and can still be pulled after the application is uninstalled and reinstalled.
The payload is as described below:
Name
Type
Description
messageList
Array
Merged message list
title
String
Title of merged messages, for example, "Chat History of the Talent Center in the Greater Bay Area"
abstractList
String
Abstract list. You can set abstract information in different formats for different message types, for example, in the sender:text format for a text message, in the sender:[image] format for an image message, or in the sender:[file] format for a file message.
compatibleText
String
Compatibility text. If the SDK on an early version does not support the merged message, the user will receive a text message with the content ${compatibleText} by default. This field is required.
Returned value
Message
Sample
// 1. Forward group messages to a one-to-one conversation.
// `message1`, `message2`, and `message3` are group messages.
let mergerMessage = chat.createMergerMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
payload: {
messageList: [message1, message2, message3],
title: 'Chat History of the Talent Center in the Greater Bay Area',
abstractList: ['allen: 666', 'iris: [Image]', 'linda: [File]'],
compatibleText: 'Upgrade your IM SDK to v2.10.1 or later to view this message.'
},
// cloudCustomData: 'your cloud custom data'
});

// 2. Send the message.
let promise = chat.sendMessage(mergerMessage);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});

Downloading a Merged Message

This API is used to download a merged message. When the merged message sent by the sender is large in size, the SDK will store it in the cloud, and the message receiver needs to download it from the cloud before viewing it.
API
chat.downloadMergerMessage(message);
Parameter
Name
Type
Description
message
Message
Message instance
Returned value
Promise
Sample
// If `downloadKey` exists, the received merged message is stored in the cloud
// and needs to be downloaded first.
if (message.type === TencentCloudChat.TYPES.MSG_MERGER && message.payload.downloadKey !== '') {
let promise = chat.downloadMergerMessage(message);
promise.then(function(imResponse) {
// After the download is successful
// the SDK will update information such as `message.payload.messageList`.
console.log(imResponse.data);
}).catch(function(imError) {
// Download failed
console.warn('downloadMergerMessage error:', imError);
});
}

Forwarding Messages One by One

To forward a single message, create a message identical to the original message through the createForwardMessage API first, and then call the sendMessage API to send the message.
API
chat.createForwardMessage(message);
Parameter
Name
Type
Description
message
Message
Message instance
Sample
let forwardMessage = chat.createForwardMessage({
to: 'user1',
conversationType: TencentCloudChat.TYPES.CONV_C2C,
payload: message, // The received or sent message instance
});
// 2. Send the message.
let promise = chat.sendMessage(forwardMessage);
promise.then(function(imResponse) {
// The message sent successfully
console.log(imResponse);
}).catch(function(imError) {
// Failed to send the message
console.warn('sendMessage error:', imError);
});

Sending a message

This API is used to send a message. You need to call any of the following message instance creation APIs to create a message instance first before calling this API to send the message instance.
createTextMessage
createTextAtMessage
createImageMessage
createAudioMessage
createVideoMessage
createCustomMessage
createFaceMessage
createFileMessage
createLocationMessage
createMergerMessage
createForwardMessage
Note
1. When this API is called to send a message instance, the SDK must be in the ready status; otherwise, the message instance cannot be sent. The SDK status can be obtained by listening for the TencentCloudChat.EVENT.SDK_READY event, which will be triggered when the SDK is in the ready status.
2. The TencentCloudChat.EVENT.MESSAGE_RECEIVED event must be listened for in order to receive newly pushed one-to-one messages, group messages, group tips, or group system notifications.
3. Messages sent by this API will not trigger the TencentCloudChat.EVENT.MESSAGE_RECEIVED event. Messages sent by the same account from another client (or through the RESTful API) will trigger the TencentCloudChat.EVENT.MESSAGE_RECEIVED event.
4. Offline push applies only to Android or iOS devices but is not supported for web.
5. onlineUserOnly and messageControlInfo cannot be used together.
API
chat.sendMessage(message, options);
Parameter
Name
Type
Description
message
Message
Message instance
options
Object
Message sending option (message content container), which is optional
The options is as described below:
Name
Type
Description
onlineUserOnly
Boolean
It specifies whether the message is sent only to online users and defaults to false. If it is set to true, the message will not be stored on the roaming server, nor counted as an unread message, nor pushed to the receiver offline. It is suitable for sending unimportant tips such as broadcast notifications. This parameter is not supported when a message is sent in an audio-video group (AVChatRoom).
offlinePushInfo
Object
For more information, see Offline Push.
messageControlInfo
Object
It is a message control configuration item.
The offlinePushInfo is as described below:
Name
Type
Description
disablePush
Boolean
true: offline push is disabled; false (default): offline push is enabled.
title
String
Offline push title. This parameter is used by both iOS and Android.
description
String
Offline push content. This parameter will overwrite the offline push display text of the message instance. If the sent message is a custom message, this parameter will overwrite message.payload.description. If both description and message.payload.description are left empty, the receiver cannot receive the offline push notification of the custom message.
extension
String
Content passed through by offline push
ignoreIOSBadge
Boolean
Specifies whether the badge count is ignored (applicable to iOS only). If this parameter is set to true, the unread message count on the application badge will not increase when the message is received by the iOS device.
androidOPPOChannelID
String
Offline push channel ID for OPPO phones that run Android v8.0 or later
The messageControlInfo is as described below:
Name
Type
Description
excludedFromUnreadCount
Boolean
true: unreadCount of the conversation is not updated (the message is stored on the roaming server); false (default)
excludedFromLastMessage
Boolean
true: lastMessage of the conversation is not updated (the message is stored on the roaming server); false (default)
excludedFromContentModeration
Boolean
true: the message is excluded from content moderation. You need to purchase the Premium edition.
Returned Value
Promise
Sample
// If the receiver is offline, the message will be stored on the roaming server
// and pushed offline on the precondition that the receiver's application switches to the background
// or the process is killed.
// The default title and content of offline push are kept.
chat.sendMessage(message);
chat.sendMessage(message, {
// If the receiver is offline, the message will be neither stored on the roaming server
// nor pushed offline.
onlineUserOnly: true
});
chat.sendMessage(message, {
offlinePushInfo: {
// If the receiver is offline, the message will be stored on the roaming server
// but will not be pushed offline.
disablePush: true
}
});
chat.sendMessage(message, {
// If the receiver is offline, the message will be stored on the roaming server
// and pushed offline on the precondition that the receiver's application switches to the background
// or the process is killed.
// The title and content of offline push can be customized at the access side.
offlinePushInfo: {
title: '', // Offline push title
description: '', // Offline push content
// Offline push channel ID for OPPO phones that run Android v8.0 or later for offline push
androidOPPOChannelID: ''
}
});
chat.sendMessage(message, {
messageControlInfo: {
// `unreadCount` of the conversation is not updated (the message is stored on the roaming server).
excludedFromUnreadCount: true,
// `lastMessage` of the conversation is not updated (the message is stored on the roaming server).
excludedFromLastMessage: true
}
});
chat.sendMessage(message, {
messageControlInfo: {
excludedFromContentModeration: true,
}
});
Feature
Limit Item
Description
One-to-one/group message
Content length
A one-to-one or group message must be no longer than 12 KB.
Sending frequency
One-to-one message: No limit for sending one-to-one messages on the client; sending through the RESTful API is subject to the frequency limit. See the corresponding API documentation. Group message: Up to 40 messages can be sent per second per group (regardless of the group type and platform interface, and this limit applies to each group separately).
Receiving frequency
No limit for one-to-one messages or group messages.
Size of a single file
SDKs support a maximum file size of 100 MB for any single file to be sent.
Note:
1. When the number of sent messages exceeds the limit, the backend will first deliver high-priority messages, and messages with the same priority will be delivered randomly. However, if the number of high-priority messages sent in a second exceeds 40, high-priority messages will also be discarded.
2. A message that has been restricted by frequency control is not delivered or stored in the message history, but a success response will be returned to the sender. Before Group Message Is Sent callback is triggered, but After a Group Message Is Sent callback is not triggered.
3. The default frequency limit for calling the RESTful API to send group messages is 200 times per second, which is a different concept from the aforementioned "limit of 40 messages per second for each group." Please distinguish it.
Please refer to Use Limits for more limits.