Search code examples
telegram-bot

How to Obtain Reactions Updates via Telegram Bot API


Good day,

Is it any chance to obtain via webhooks or long-pooling requests updates related to reactions to messages which was posted by bot? Or at least obtain any reactions updates in channel/group to which a bot was added.

In documentation found API Method: https://core.telegram.org/bots/api#getupdates

But based on how the response model looks like there are no chance to obtain updates related to reactions.

Did someone has solved such issue?

Thank you in advance


Solution

  • Situation changed! As of Telegram Bot API 7.0 your bot can set one reaction per message and it can receive reactions.

    First of all, To receive reaction updates you must explicitly specify that your bot want to receive reaction updates in your getUpdates/setWebhook call.

    A call to getUpdates/setWebhook usually hidden inside a library you use for Telegram Bot API. A library I use has special object BotOptions supplied at bot start. Your library might have something like that.

    getUpdates/setWebhook http requests have parameter allowed_updates, that contains a json-serialized list of all update types you want to receive. Names correspond to Update field names. For example, 'message' to receive new messages. See Update for a complete list of available update types. Specify an empty list to receive all update types except 'chat_member', 'message_reaction', and 'message_reaction_count' (default). If not specified, the previous setting will be used.

    'message_reaction' and 'message_reaction_count' are types we need, so, you have to specify a list of desired update types, including 'message_reaction' for personal chats and 'message_reaction_count' for chats with anonymous reactions.

    After that you bot will receive updates with reactions.