skip to Main Content

I am making a telegram bot using node.js and node-telegram-bot-api library.
I answer on callback_query and want to change my inline keybord. The code below shows how I am trying to use this method, but when I tap on keyboard in telegram, it just dissapears:

bot.on('callback_query', msg => {
    bot.editMessageReplyMarkup({
        reply_markup:  {
            inline_keyboard: [
                [
                    {
                        text: "text1",
                        callback_data: "data1"
                    }
                ],
                [
                    {
                        text: "text2",
                        callback_data: "data2"
                    }
                ]
            ]
        }
    }, {
        chat_id: msg.from.id, 
        message_id: msg.message.message_id
    });
})

It happens without any errors, I don’t undestand why. Any ideas?
The method’s discription on GitHub.

2

Answers


  1. Chosen as BEST ANSWER

    reply_markup isn't needed here so this will be OK:

    bot.editMessageReplyMarkup({
            inline_keyboard: [
                [
                    {
                        text: "text1",
                        callback_data: "data1"
                    }
                ],
                [
                    {
                        text: "text2",
                        callback_data: "data2"
                    }
                ]
            ]
    }, {
        chat_id: msg.from.id, 
        message_id: msg.message.message_id
    });
    

    Wanted to delete this but maybe someone as inattentive as me


  2. const markupTest = {
      inline_keyboard: [
        [{
          text: "Ваш ответ принят",
          callback_data: 'done'
        }],
      ]
    };
    
    bot.telegram.editMessageReplyMarkup(chatId, messageId, inlineId,  markupTest);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search