Skip to main content

Reactions

Reactions allow users to express their emotions or feedback on a chat message quickly and easily using emojis.

Supported Reactions

TypeEmoji
thumbsup👍
clap👏
slightly_smiling_face🙂
smiley😄
heart
eyes👀
white_check_mark
confused😕
thumbsdown👎

Commands

Deletes a reaction from a specific message in a specified channel. This operation is idempotent and requires the channel and message to be accessible to the user.
Retrieves a list of reactions for a specific message in a specified channel. Supports pagination through limit and offset parameters.
Sends a reaction to a specific message in a specified channel. This operation requires the channel to be accessible to the user.

Setting Reactions

import {
ConversationsClient,
SendMessageReactionCommand,
DeleteMessageReactionCommand
} from '@wildix/xbees-conversations-client';

// Initialize the client with the desired configuration
const client = new ConversationsClient({...});

const channelId = '<channel-id>';
const messageId = '<message-id>';

// Send a reaction for a specific message for the user. If service token is used, set userId configuration.
await client.send(
new SendMessageReactionCommand({
channelId,
messageId,
reactionType: "thumbsdown",
userId: '<user-id>' // In case of service token authorization.
}),
);

// Delete a reaction for a specific message for the user. If service token is used, set userId configuration.
await client.send(
new DeleteMessageReactionCommand({
channelId,
messageId,
reactionType: "thumbsdown",
userId: '<user-id>' // In case of service token authorization.
}),
);

Retrieve Reactions

Messages returned by the APIs automatically include the 10 most recent reactions. You can also retrieve more reactions and paginate using the following logic. Note that the maximum value for the Limit parameter is 300 and for the Offset parameter is 1000:

import {
ConversationsClient,
ListMessageReactionsCommand
} from '@wildix/xbees-conversations-client';

// Initialize the client with the desired configuration
const client = new ConversationsClient({...});

const channelId = '<channel-id>';
const messageId = '<message-id>';

// Retrieve reactions with pagination
const reactionsResponse = await client.send(
new ListMessageReactionsCommand({
channelId,
messageId,
limit: 50,
offset: 150
}),
);

console.log('Reactions retrieved successfully', reactionsResponse);