For what we need to pass data to callback button in in simple keyboard (not inline), if thats doesn’t matter?
Example:
const mainMenuKeyboard = Markup.InlineKeyboard([
Markup.callbackButton('Add', 'addAction),
]).resize().extra();
Now, If I want to catch "addAddress" action, I can just do this:
bot.action('addAction',(ctx) => <WHATEVER>);
Everything works just fine& But, when I want to use simple keyboard (not inline) in my project I cant catch this action using "bot.action("addAction")" I have to use "bot.hears("Add")" :
const mainMenuKeyboard = Markup.keyboard([
Markup.callbackButton('Add', 'addAction),
]).resize().extra();
Don’t work
bot.action('addAction',(ctx) => <WHATEVER>);
Work
bot.hears('Add',(ctx) => <WHATEVER>);
You shouldn't be using Markup.callbackButton (which is InlineKeyboardButton on the Bot API) inside Markup.keyboard(ReplyKeyboardMarkup).
According to Telegram Bot API docs, Markup.keyboard(ReplyKeyboardMarkup) should contain Array of Arrays (not just an array BTW, fix that as well) of KeyboardButton. And Markup.callbackButton(which is Inlinekeyboardbutton on the API) should be used for InlineKeyboard (not reply keyboard).
For more examples on how to use these on telegraf, check this example out
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With