const call: Call;
await call.sendReaction({ type: 'raised-hand' });
Reactions
Reactions allow call participants to send emojis in real-time.
Custom events let participants send and receive arbitrary WebSocket messages. For example, if you want to implement a drawing feature in your call, you can use custom events for synchronizing the drawing board between participants.
Reactions
Sending reactions
You can send a reaction using the sendReaction
method of a Call
instance.
The value of the type
attribute can be any string.
It’s also possible to provide additional data for the reaction:
const call: Call;
await call.sendReaction({
type: 'raised-hand',
emoji_code: ':raise-hand:',
custom: { clearAfterTimeout: true },
});
The emoji_code
attribute is used by the SDK components to decide which emoji to display on the UI.
The custom
property can contain any data.
Receiving reactions
Reactions are only delivered to clients that are watching the call.
The participant state will contain the latest reaction of each participant:
const { participants } = call.state;
// or subscribe to call.state.participants$
const reactions = participants.map((p) => p.reaction);
You can also subscribe to the call.reaction_new
WebSocket event to receive reactions. For more information, check out our Events guide.
Clearing reactions
If you’re using the participant state for receiving reactions, you can also clear the latest reaction using the resetReaction
method:
const { participants } = call.state;
// or subscribe to call.state.participants$
call.resetReaction(participants[0].sessionId);
This is a local action, it won’t send any WebSocket messages. It’s helpful if you only want to display reactions for a set period of time.