Skip to content

Reactions

With XMTP, reactions are represented as objects with the following keys:

Reaction object

The reaction type contains the following

{
  reference: message.id, //ID of the message being reacted to
  schema: "unicode", //Schema of the reaction (Unicode, shortcode, or custom)
  action: action, //Action of the reaction (added or removed)
  content: emoji, //String representation of the reaction (smile, for example) to be interpreted by clients
};

Receive a reaction

Now that you understand how reactions are represented, you can receive them in your app. Here's an example of how you can receive a reaction in your app:

const { content, typeId, getMessageById } = context;
 
if (typeId === "reaction") {
  //Get the message that was reacted to
  const msg = await getMessageById(content.reference);
  // Use reaction...
  const { action, content: emoji } = content;
}