ITUIConversationService

ITUIConversationService

Methods

switchConversation(conversationID) → {Promise.<any>}

Switch conversation

Example
// Switch to public001 group conversation
let promise = TUIConversationService.switchConversation('GROUPpublic001');
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
conversationID String

Conversation ID, conversationID generation rules: one-to-one chat (C2C${userID}), group chat (GROUP${groupID}).

Returns:
Type
Promise.<any>

getConversationProfile(conversationID) → {Promise.<any>}

Get conversation profile Note: Service API is mainly used for cross-component calls

Example
// Get public001 group conversation profile
let promise = TUIConversationService.getConversationProfile('GROUPpublic001');
promise.then((chatResponse) => {
 console.log(chatResponse.data.conversation); // Conversation profile
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
conversationID String

Conversation ID

Returns:
Type
Promise.<any>

clearHistoryMessage(conversationID) → {Promise.<any>}

Clear history messages with one click

Example
let promise = TUIConversationService.clearHistoryMessage('GROUPpublic001');
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
conversationID String

Conversation ID

Returns:
Type
Promise.<any>

setConversationDraft(options) → {Promise.<any>}

Set conversation draft

Examples
// Set conversation draft
let promise = TUIConversationService.setConversationDraft({
  conversationID: 'GROUPpublic001',
  darftInfo: {
   html: 'test';
   abstract: 'test';
  }
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
// Clear conversation draft
let promise = TUIConversationService.setConversationDraft({
  conversationID: 'GROUPpublic001',
});
promise.catch((error) => {
 // Business side can catch exceptions through promise.catch for error handling
});
Parameters:
Name Type Description
options SetConversationDraftParams

Parameter options

Returns:
Type
Promise.<any>