inline_keyboard,
when the callback button is pressed I get callback_query.
I want to answer with answerCallbackQuery but where find callback_query_id ?
thanks.
When you press a button of a inline_keyboard, your bot receives an Update containing an Object called "CallbackQuery" (Official Reference).
If you see, it contains a key:value pair called "id", which is what you are looking for and what you have to pass to answerCallbackQuery method.
Thanks @alexandercerutti. But not works.
In debug i receive:
node-telegram-bot-api Process Update callback_query {"id":"221087997479747530","from":....
I send
node-telegram-bot-api HTTP request: {"form":[{"callback_query_id":"221087997479747530","text":"ok"}]
I receive:
Unhandled rejection Error: ETELEGRAM: 400 Bad Request: QUERY_ID_INVALID
This is my code:
bot.on("callback_query",(msg)=>{
var opts = {
callback_query_id: msg.id,
text: "ok"
}
bot.answerCallbackQuery([opts]);
})
bot.answerCallbackQuery doesn't need an Array as parameter but just an object.
The syntax used in the documentation is a bit error-prone. In fact, [opts] usually means that the parameter opts is optional, while one of the properties, callback_query_id, is mandatory.
So, try with:
bot.on("callback_query", q => {
bot.answerCallbackQuery({
callback_query_id: q.id,
text: "ok",
});
});
thank you very much.
Most helpful comment
bot.answerCallbackQuerydoesn't need an Array as parameter but just an object.The syntax used in the documentation is a bit error-prone. In fact,
[opts]usually means that the parameteroptsis optional, while one of the properties,callback_query_id, is mandatory.So, try with: