Merge and Forward | Display of Merged Message | Click Merged Message to Download Message List for Display |
| | |
sendMessage
API when you need to send a merged message.chat.createMergerMessage(options);
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. |
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 | Digest list. You can set digest 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 early SDK version does not support the merged message, the user will receive a text message with the content ${compatibleText} by default. This field is required. |
Message
// 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 Chat 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) {// Message sent successfullyconsole.log(imResponse);}).catch(function(imError) {// Failed to send the messageconsole.warn('sendMessage error:', imError);});
chat.downloadMergerMessage(message);
Name | Type | Description |
message | Message | Message instance |
Promise
// 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 failedconsole.warn('downloadMergerMessage error:', imError);});}
createForwardMessage
API first, and then call the sendMessage
API to send the message.chat.createForwardMessage(message);
Name | Type | Description |
message | Message | Message instance |
Message
let forwardMessage = chat.createForwardMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,payload: message, // Message instance for the received or sent message// cloudCustomData: 'your cloud custom data'});// 2. Send the message.let promise = chat.sendMessage(forwardMessage);promise.then(function(imResponse) {// Message sent successfullyconsole.log(imResponse);}).catch(function(imError) {// Failed to send the messageconsole.warn('sendMessage error:', imError);});
Was this page helpful?