Browse SDKs · WASM
SDKsWASM

Create an @ message

Create a group-chat text message with @ mentions using the WASM SDK.

Copy

Parameters

ParameterTypeRequiredDescription
textstringYesMessage body. Stable markers such as @userID are recommended.
atUserIDListstring[]YesIDs of the mentioned users. To mention everyone, first obtain the dedicated marker from getAtAllTag().
atUsersInfoAtUserInfo[]NoUser IDs and their display names within the group.
messageMessageItemNoOriginal message being referenced.
const { data: message } = await openimsdk.createTextAtMessage({
  text: '@user_a please confirm',
  atUserIDList: ['user_a'],
  atUsersInfo: [{ atUserID: 'user_a', groupNickname: 'Alex' }],
});

When the Promise resolves, it returns only a pending message object. This message can be sent only to a group chat. Creating it does not change the conversation's @ state or trigger a new-message event.

Mention everyone

Do not hard-code the mention-all marker in application code. Obtain the current SDK marker, then include it in both the message body and atUserIDList:

const { data: atAllTag } = await openimsdk.getAtAllTag();
const { data: message } = await openimsdk.createTextAtMessage({
  text: `${atAllTag} please review the group announcement`,
  atUserIDList: [atAllTag],
});

When getAtAllTag() resolves, data contains the string marker. It only reads an SDK convention; it does not create a message or trigger an event.