Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Create conversation group

Create a new conversation group and optionally associate an initial conversation.

Copy

When creating a standard conversation group, supply a name, display sort order, and group category. To immediately link an existing conversation, provide its conversationID.

Code example

import sdk, {
  ConversationGroupType,
  CreateConversationGroupReq,
  CreateConversationGroupResp,
} from '@openimsdk/imsdk';

const request: CreateConversationGroupReq = {
  name: 'Work',
  order: 100,
  conversationGroupType: ConversationGroupType.ConversationGroupTypeNormal,
  conversationID: conversationID,
};
const response: CreateConversationGroupResp = await sdk.createConversationGroup(request);
const group = response.conversationGroup;

Parameters

ParameterTypeRequiredDescription
namestringYesDisplay name for the group.
ordernumberYesNumerical sort index defined by application convention.
conversationGroupTypeConversationGroupTypeYesGroup type (ConversationGroupTypeNormal or ConversationGroupTypeFilter).
conversationIDstringNoInitial conversation ID to add into the newly created group.
exstringNoCustom application metadata string.

Return value

Returns a Promise that resolves to a CreateConversationGroupResp object:

PropertyTypeDescription
conversationGroupIMConversationGroupThe newly created conversation group object.

State changes after the call

Once the Promise resolves, update your local group list by merging the new record using conversationGroupID. Associated clients and other active devices observe changes via EventOnConversationGroupAdded. For complete event lifecycle details, see Conversation groups overview.