
BotKit by Fedify 
@botkit@hollo.social · Reply to BotKit by Fedify :botkit:'s post
Continuing our emoji reaction feature announcement, we're also introducing two new event handlers—Bot.onReact
and Bot.onUnreact
—that let your bot respond when users react to posts:
// When someone adds an emoji reaction to a post
bot.onReact = async (session, reaction) => {
// Only respond when the reaction is to your bot's post
if (reaction.message.actor.id?.href === session.actorId.href) {
console.log(`${reaction.actor.preferredUsername} reacted with ${reaction.emoji}`);
// You can respond differently based on the emoji
if (reaction.emoji === "❤️") {
await session.publish(
text`Thanks for the love, ${reaction.actor}!`,
{ visibility: "direct" }
);
}
}
};
// When someone removes their emoji reaction
bot.onUnreact = async (session, reaction) => {
if (reaction.message.actor.id?.href === session.actorId.href) {
console.log(`${reaction.actor.preferredUsername} removed their ${reaction.emoji} reaction`);
// Optional: respond to reaction removal
await session.publish(
text`I noticed you removed your ${reaction.emoji} reaction, ${reaction.actor}.`,
{ visibility: "direct" }
);
}
};
These event handlers open up interesting interaction possibilities—your bot can now track popular reactions, respond to specific emoji feedback, or create interactive experiences based on reactions.
Want to try these features now? You can install the development version from JSR today:
deno add jsr:@fedify/botkit@0.2.0-dev.86+cdbb52a2
The full documentation for these features will be available when BotKit 0.2.0 is officially released!