service events

telegram sends many changes as updates or service messages: joins, leaves, reactions, pins, payments, forum topic changes, boosts, and chat migrations.

new members

joins.ts
bot.on("message", async (ctx) => {
  const members = ctx.message?.new_chat_members;
  if (!members?.length) return;

  await ctx.reply("welcome " + members.map((u) => u.first_name).join(", "));
});

reactions

reaction updates are not part of the default update set. add message_reaction to allowedUpdates when polling.

reactions.ts
bot.on("message_reaction", async (ctx) => {
  const reaction = ctx.update.message_reaction!;
  console.log(reaction.user?.id, reaction.old_reaction, reaction.new_reaction);
});

pinned messages

pinned.ts
bot.on("message", async (ctx) => {
  if (!ctx.message?.pinned_message) return;
  await ctx.reply("new pinned message");
});

common service fields

field/updatewhat it means
new_chat_membersusers joined a group
left_chat_membera user left or was removed
pinned_messagea message was pinned
successful_paymenta payment completed
forum_topic_createda forum topic was created
message_reactiona user changed reactions on a message
service events are normal bot logic. route them, test them with @yaebal/test, and include them in allowedUpdates when telegram does not send them by default.