Reputation: 93
I use node_telegram_bot_api for my Telegram bot. I create an inline keyboard buttons :
var bot = new loader.Bot(config.botToken,{polling:true});
var options = {
reply_markup: JSON.stringify({
inline_keyboard: [
[{text: 'Some button text 1', callback_data: '1'}], // Clicking will send "1"
[{text: 'Some button text 2', callback_data: '2'}], // Clicking will send "2"
[{text: 'Some button text 3', callback_data: '3'}] // Clicking will send "3"
]
})
};
bot.sendMessage(msg.from.id, "Click a button to display data", options);
And I told a callback_query function for listen to click the buttons:
bot.on('callback_query', function(msg) {
var user = msg.from.id;
var data = msg.data;
bot.sendMessage(msg.from.id, "You clicked button with data '"+ data +"'");
});
After clicking on the buttons this function is not implemented. Can you help me?
Upvotes: 1
Views: 2268
Reputation: 8785
This test woks for me:
https://ide.c9.io/jlvaquero/test
Try to compare it with your project. My 2 cents it is your node_telegram_bot_api version.
Upvotes: 1