Skip to content

How to get reactions to messages? #1266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
autoantwort opened this issue May 7, 2025 · 1 comment
Open

How to get reactions to messages? #1266

autoantwort opened this issue May 7, 2025 · 1 comment

Comments

@autoantwort
Copy link

I want to get reactions to my messages and use the following code:

const TelegramBot = require('node-telegram-bot-api');
const TOKEN = '***';

const bot = new TelegramBot(TOKEN, {
    polling: {
        params: {
            allowed_updates: ["message", "message_reaction"],
        }
    }
});

console.log(TelegramBot.messageTypes)

bot.on('message', (msg) => {
    bot.sendMessage(msg.chat.id, 'Try reacting to this message!');
});

bot.on('message_reaction', (reaction) => {
    console.log('Reaction received (message_reaction):', reaction);
});
bot.on("message_reaction_count", async (reaction) => {
    console.log("message_reaction_count", reaction);
});
console.log('Bot started with polling enabled');

But when i send the bot a message and react to it I don't get a update. Do you have a idea what the problem could be?

Console output

✗ DEBUG=* bun run ./test.js
  node-telegram-bot-api polling with options: {"allowed_updates":["message","message_reaction"],"offset":0,"timeout":10} +0ms
  node-telegram-bot-api HTTP request: {"form":{"allowed_updates":["message","message_reaction"],"offset":0,"timeout":10},"method":"POST","url":"https://api.telegram.org/bot***/getUpdates","simple":false,"resolveWithFullResponse":true,"forever":true} +0ms
[
  "text", "animation", "audio", "channel_chat_created", "contact", "delete_chat_photo", "dice",
  "document", "game", "group_chat_created", "invoice", "left_chat_member", "location", "migrate_from_chat_id",
  "migrate_to_chat_id", "new_chat_members", "new_chat_photo", "new_chat_title", "passport_data",
  "photo", "pinned_message", "poll", "sticker", "successful_payment", "supergroup_chat_created",
  "video", "video_note", "voice", "video_chat_started", "video_chat_ended", "video_chat_participants_invited",
  "video_chat_scheduled", "message_auto_delete_timer_changed", "chat_invite_link", "chat_member_updated",
  "web_app_data", "message_reaction"
]
Bot started with polling enabled
  node-telegram-bot-api polling data [{"update_id":828783828,"message":{"message_id":985,"from":{"id":330034405,"is_bot":false,"first_name":"***","username":"***","language_code":"en"},"chat":{"id":330034405,"first_name":"***","username":"***","type":"private"},"date":1746611751,"text":"wer"}}] +5s
  node-telegram-bot-api updated offset: 828783829 +1ms
  node-telegram-bot-api Process Update {"update_id":828783828,"message":{"message_id":985,"from":{"id":330034405,"is_bot":false,"first_name":"***","username":"***","language_code":"en"},"chat":{"id":330034405,"first_name":"***","username":"***","type":"private"},"date":1746611751,"text":"wer"}} +5s
  node-telegram-bot-api Process Update message {"message_id":985,"from":{"id":330034405,"is_bot":false,"first_name":"***","username":"***","language_code":"en"},"chat":{"id":330034405,"first_name":"***","username":"***","type":"private"},"date":1746611751,"text":"wer"} +0ms
  node-telegram-bot-api HTTP request: {"form":{"chat_id":330034405,"text":"Try reacting to this message!"},"method":"POST","url":"https://api.telegram.org/bot***/sendMessage","simple":false,"resolveWithFullResponse":true,"forever":true} +1ms
  node-telegram-bot-api Emitting text: {"message_id":985,"from":{"id":330034405,"is_bot":false,"first_name":"***","username":"***","language_code":"en"},"chat":{"id":330034405,"first_name":"***","username":"***","type":"private"},"date":1746611751,"text":"wer"} +0ms
  node-telegram-bot-api Text message +0ms
  node-telegram-bot-api setTimeout for 300 miliseconds +1ms
  node-telegram-bot-api polling with options: {"allowed_updates":["message","message_reaction"],"offset":828783829,"timeout":10} +305ms
  node-telegram-bot-api HTTP request: {"form":{"allowed_updates":["message","message_reaction"],"offset":828783829,"timeout":10},"method":"POST","url":"https://api.telegram.org/bot***/getUpdates","simple":false,"resolveWithFullResponse":true,"forever":true} +305ms
  node-telegram-bot-api polling data [] +10s
  node-telegram-bot-api setTimeout for 300 miliseconds +1ms
  node-telegram-bot-api polling with options: {"allowed_updates":["message","message_reaction"],"offset":828783829,"timeout":10} +305ms
  node-telegram-bot-api HTTP request: {"form":{"allowed_updates":["message","message_reaction"],"offset":828783829,"timeout":10},"method":"POST","url":"https://api.telegram.org/bot***/getUpdates","simple":false,"resolveWithFullResponse":true,"forever":true} +10s
Image

@Say-M
Copy link

Say-M commented May 11, 2025

I don't know for some reason node-telegram-bot-api can not handle this properly.

Just hit this link from your browser (only once), and after that you will get updates on message reactions
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates?allowed_updates=["update_id","message","edited_message","channel_post","edited_channel_post","inline_query","chosen_inline_result","callback_query","shipping_query","pre_checkout_query","poll","poll_answer","my_chat_member","chat_member"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants