node-telegram-bot-api: Inline Keyboard, Callback_query not being called
It is amazing tool for NodeJS.
But I am stuck with in-line keyboard.
bot.onText(/(.+)$/, function (msg, match) {
const opts = {
reply_markup: {
inline_keyboard: [
[
{
text: 'Edit Text',
callback_data: 'edit'
}
]
]
}
};
bot.sendMessage(msg.from.id, 'Original Text', opts);
});
bot.on("callback_query", function(callbackQuery) {
// 'callbackQuery' is of type CallbackQuery
console.log(callbackQuery);
});
Referring to the above code, callback_query
is not executed upon clicking Edit Text
inline-button
How can i solve this?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24 (2 by maintainers)
I found the problem, @GochoMugo… in my package.json I had “node-telegram-bot-api”: “^0.21.1”, changed the version and it’s worked! Thanks!
Works for me.
@ravi72munde I believe the latest version on npm already supports callback queries, etc.
OP has not reacted to any comments. I’ll go ahead and assume the issue is resolved by @luiguild’s solution above. Thanks everyone. 👍
#ANS
@mnb3000 but in this case anyone that send one message with the same content, the bot will execute the function 😨
It’s not possible using something like
callback_data: "Opt1",
that is used in inline keyboard?