
createConversationGroup API to create a conversation group. After the API is called successfully, the SDK distributes the TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED and TencentCloudChat.EVENT.CONVERSATION_GROUP_LIST_UPDATED events.51010 error will be reported. Groups that are no longer used should be promptly deleted.chat.createConversationGroup(options);
options parameter is of the Object type. It contains the following attribute values:Name | Type | Description |
conversationIDList | String | List of conversation IDs |
groupName | String | Conversation group name, which can be up to 32 bytes in length |
Promiselet promise = chat.createConversationGroup({conversationIDList: ['GROUPtest', 'C2Cexample'],groupName: 'Suppliers',});promise.then(function(imResponse) {// Created the conversation group successfullyconst { successConversationIDList, failureConversationIDList } = imResponse.data;// successConversationIDList - List of IDs of the conversations that were created successfully// Get the conversation listconst conversationList = chat.getConversationList(successConversationIDList);// failureConversationIDList - List of IDs of the conversations that failed to be createdfailureConversationIDList.forEach((item) => {const { conversationID, code, message } = item;});}).catch(function(imError){console.warn('createConversationGroup error:', imError);});
deleteConversationGroup API to delete a conversation group. After the API is deleted successfully, the SDK distributes the TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED and TencentCloudChat.EVENT.CONVERSATION_GROUP_LIST_UPDATED events.51009 error will be reported.chat.deleteConversationGroup(groupName);
Name | Type | Description |
groupName | String | Conversation group name, which can be up to 32 bytes in length |
Promiselet promise = tim.deleteConversationGroup('Suppliers');promise.then(function() {// Deleted successfully}).catch(function(imError){console.warn('deleteConversationGroup error:', imError);});
renameConversationGroup API to rename a conversation group. After the API is renamed successfully, the SDK distributes the TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED and TencentCloudChat.EVENT.CONVERSATION_GROUP_LIST_UPDATED events.chat.renameConversationGroup(options);
options parameter is of the Object type. It contains the following attribute values:Name | Type | Description |
oldName | String | Old group name |
newName | String | New group name, which can be up to 32 bytes in length |
Promiselet promise = chat.renameConversationGroup({oldName: 'Suppliers_old',newName: 'Suppliers_new'});promise.then(function(imResponse) {// Renamed successfully}).catch(function(imError){console.warn('renameConversationGroup error:', imError);});
getConversationGroupList API to get the list of conversation groups.chat.getConversationGroupList();
Promiselet promise = chat.getConversationGroupList();promise.then(function(imResponse) {const groupNameList = imResponse.data; // Conversation group name list});
// Obtain all conversations in a specified conversation grouplet promise = chat.getConversationList({ groupName: 'Suppliers' });promise.then(function(imResponse) {const conversationList = imResponse.data.conversationList; // Conversation list});
addConversationsToGroup API to add a conversation to the group. After the API is called successfully, the SDK distributes the TencentCloudChat.EVENT.CONVERSATION_GROUP_LIST_UPDATED event.chat.addConversationsToGroup(options);
options parameter is of the Object type. It contains the following attribute values:Name | Type | Description |
conversationIDList | String | List of conversation IDs |
groupName | String | Conversation group name, which can be up to 32 bytes in length |
Promiselet promise = chat.addConversationsToGroup({conversationIDList: ['GROUPtest', 'C2Cexample'],,groupName: 'Suppliers_new',});promise.then(function(imResponse) {// Added the conversation to the group successfullyconst { successConversationIDList, failureConversationIDList } = imResponse.data;// successConversationIDList - List of IDs of the conversations that were created successfully// Get the conversation listconst conversationList = chat.getConversationList(successConversationIDList);// failureConversationIDList - List of IDs of the conversations that failed to be createdfailureConversationIDList.forEach((item) => {const { conversationID, code, message } = item;});}).catch(function(imError){console.warn('addConversationsToGroup error:', imError);});
deleteConversationsFromGroup API to delete a conversation from a group. After the API is called successfully, the SDK distributes the TencentCloudChat.EVENT.CONVERSATION_GROUP_LIST_UPDATED event.chat.deleteConversationsFromGroup(options);
options parameter is of the Object type. It contains the following attribute values:Name | Type | Description |
conversationIDList | String | List of conversation IDs |
groupName | String | Conversation group name, which can be up to 32 bytes in length |
Promiselet promise = chat.deleteConversationsFromGroup({conversationIDList: ['GROUPtest', 'C2Cexample'],,groupName: 'Suppliers_new',});promise.then(function(imResponse) {// Deleted the conversation from the group successfullyconst { successConversationIDList, failureConversationIDList } = imResponse.data;// successConversationIDList - List of IDs of the conversations that were created successfully// Get the conversation listconst conversationList = chat.getConversationList(successConversationIDList);// failureConversationIDList - List of IDs of the conversations that failed to be createdfailureConversationIDList.forEach((item) => {const { conversationID, code, message } = item;});}).catch(function(imError){console.warn('deleteConversationsFromGroup error:', imError);});
let onConversationGroupListUpdated = function(event) {console.log(event.data); // List of all conversation groups}chat.on(TencentCloudChat.EVENT.CONVERSATION_GROUP_LIST_UPDATED, onConversationGroupListUpdated);
let onConversationInGroupUpdated = function(event) {const { groupName, conversationList } = event.data;// groupName - Conversation group name// conversationList - List of conversations in the group}chat.on(TencentCloudChat.EVENT.CONVERSATION_IN_GROUP_UPDATED, onConversationInGroupUpdated);
피드백