Search code examples
javascriptnode.jsnode-telegram-bot-api

Update menu in telegram bot


I have a bot that he only show the user a menu. Written using node-telegram-bot-api. I have updated the links in the menu and I want to update all the users to the new menu without clicking "start" again.

I tried resetting the bot and deleting botdata but it didn't send the menu again.


Solution

  • You have to save somewhere the message_id along with the chat_id fields that you'll receive in the reply whenever you send a message, for every chat where the message got sent and then call the method bot.editMessageReplyMarkup with the appropriate parameters (like message_id). But caution: if the user blocked the bot or deleted the chat, you'll receive an error. So you'll have also to delete the current message_id from your records if this will happen.