I have an inline keyboard which it's buttons come from a JSON obj like RSP. It is something like this:
[{"caption", "A"},
{"caption", "B"},
{"caption", "C"}]
the number of objects in RSP and the values of them("A", "B",...) are not constant and I get them by calling an API.
Now I don't know how to handle the response of each key.
Should I use Scenes or something else?
Thanks for any help.
Hi @kmahsi
We have few solutions here:
Dispatch callback query data manually:
bot.on('callback_query', (ctx) => {
console.log(ctx.callbackQuery.data)
})
Or using predicate function:
function predicateFn (callbackData) {
return callbackData === 'A' || callbackData === 'B'
}
bot.action(predicateFn, ({ reply }) => reply('foo'))
Hi @dotcypress
Thanks for your answer.
What is the application of this "action" method?
Is it just about inline keyboard and callbackQuerys?
Another thing is that I have many objects like RSP and each of them have its own inline keyboard and they have different logics from each other, thus your first solution doesn't work in this situation ( It handles every call back query in the same way.)
But I don't know if your second solution works or not.
@kmahsi Yes, the second solution will work.