tencent cloud

Feedback

Last updated: 2023-07-17 17:01:40

    Feature Description

    The Chat SDK provides an API for getting conversations, which can be used to get the Conversation object information of one or multiple specified conversations.

    Getting the Conversation List

    Note
    1. The profile in the conversation list obtained through this API is incomplete. It contains only the information which is sufficient to render the conversation list, such as profile photo and nickname. To query the detailed conversation profile, see getConversationProfile.
    2. By default, the client can pull 100 recent conversations from the cloud. If you upgrade to the Premium edition, up to 500 recent conversations can be pulled from the cloud.
    3. The retention period of a conversation is the same as that of the last message, which is seven days by default.
    API
    chat.getConversationList(options);
    Parameter
    Name
    Type
    Description
    options
    undefined | Array | Object
    If options is undefined, the SDK will return all the conversations.
    if options is of the Array type, it shall not be empty, the SDK will return specified conversations.
    if options is of the Object type, as {type, markType, groupName}, the SDK will return filtered conversations.
    Returned value
    Promise
    Sample
    let promise = chat.getConversationList();
    promise.then(function(imResponse) {
    // This full conversation list will overwrite the original conversation list.
    const conversationList = imResponse.data.conversationList;
    // Whether synchronizing the conversation list from the cloud is completed
    const isSyncCompleted = imResponse.data.isSyncCompleted;
    }).catch(function(imError){
    console.warn('getConversationList error:', imError); // Error information
    });
    // Get the list of specified conversations
    let promise = chat.getConversationList([conversationID1, conversationID2]);
    promise.then(function(imResponse) {
    // List of specified conversations that already exist in the cache
    const conversationList = imResponse.data.conversationList;
    }).catch(function(imError){
    console.warn('getConversationList error:', imError); // Error information
    });
    // Get all group conversations
    let promise = chat.getConversationList({ type: TencentCloudChat.TYPES.CONV_GROUP });
    promise.then(function(imResponse) {
    const conversationList = imResponse.data.conversationList; // Conversation list
    });
    // Obtain all conversations that are marked as "favorite"
    let promise = chat.getConversationList({ markType: TencentCloudChat.TYPES.CONV_MARK_TYPE_STAR });
    promise.then(function(imResponse) {
    const conversationList = imResponse.data.conversationList; // Conversation list
    });
    // Obtain all conversations in a specified conversation group
    let promise = chat.getConversationList({ groupName: 'Suppliers' });
    promise.then(function(imResponse) {
    const conversationList = imResponse.data.conversationList; // Conversation list
    });

    Getting the Detailed Conversation Profile

    API
    chat.getConversationProfile(conversationID);
    Parameter
    Name
    Type
    Description
    conversationID
    String
    Conversation ID. Valid values:
    C2C${userID} (for a one-to-one chat)
    GROUP{groupID} (for a group chat)
    @TIM#SYSTEM (for a system notification conversation)
    Returned value
    Promise
    Sample
    let promise = chat.getConversationProfile(conversationID);
    promise.then(function(imResponse) {
    // Conversation profile obtained successfully
    console.log(imResponse.data.conversation); // Conversation profile
    }).catch(function(imError) {
    console.warn('getConversationProfile error:', imError); // Failed to obtain the conversation profile
    });
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support