Browse SDKs · WASM
SDKsWASM

Resolve a conversation ID

Get a conversation ID from a chat target and conversation type.

Copy

When you need only a conversation ID rather than the complete conversation object, call getConversationIDBySessionType(). Pass the other user's ID for a one-to-one chat or the group ID for a group chat. Do not construct the ID in the application layer.

import { SessionType } from '@openim/wasm-client-sdk';

const { data: conversationID } =
  await openimsdk.getConversationIDBySessionType({
    sourceID: targetUserID,
    sessionType: SessionType.Single,
  });

The successful Promise returns a string. Pass it directly to conversation settings, read-state, hiding, and deletion methods. This query does not trigger a conversation event.