4

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.

YakovL
  • 7,557
  • 12
  • 62
  • 102
ExsaNik
  • 143
  • 2
  • 10

2 Answers2

7

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

ExsaNik
  • 143
  • 2
  • 10
  • this is very helpful. Same applies to Telegraf's `context.editMessageReplyMarkup`: instead of `ctx.editMessageReplyMarkup(markup)` after `const markup = Markup.inlineKeyboard(...)`, one has to use `ctx.editMessageReplyMarkup(markup.reply_markup)`. This is awkward and docs don't really help about it, so many thanks! – YakovL Oct 18 '21 at 13:10
0
const markupTest = {
  inline_keyboard: [
    [{
      text: "Ваш ответ принят",
      callback_data: 'done'
    }],
  ]
};

bot.telegram.editMessageReplyMarkup(chatId, messageId, inlineId,  markupTest);
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
  • Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Jul 26 '22 at 11:13
  • Please read [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). While this code block may answer the OP's question, this answer would be much more useful if you explain how this code is different from the code in the question, what you've changed, why you've changed it and why that solves the problem without introducing others. – Saeed Zhiany Jul 27 '22 at 03:06