A
A
Alexey2017-04-22 13:32:02
JSON
Alexey, 2017-04-22 13:32:02

Telegram bot api how to use answercallbackquery to display alert?

There was a misunderstanding how to call answercallbackquery https://core.telegram.org/bots/api#answercallbackquery ?
Endpoint:
https://api.telegram.org/bot/answerCallbackQuery
making a request:

{
  "callback_query_id":"123123123123123123",
  "text":"alert",
  "url":"http://ya.ru"
}

I get a response:
{
  "ok": false,
  "error_code": 400,
  "description": "Bad Request: QUERY_ID_INVALID"
}

Please tell me what I'm doing wrong and share the json request code for an example?
Experimentally, we managed to find out that an alert can be displayed if GetUpdate was not called after the request

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Ly, 2017-04-22
@lolobrigita

In the callback_query_id field, you need to write the id that you received when requesting a callback

S
srchost, 2018-05-22
@srchost

// Ответ на нажатие кнопок
function send_answerCallbackQuery($token, $callback_query_id, $text, $show_alert){
  file_get_contents("https://api.telegram.org/bot".$token."/answerCallbackQuery?callback_query_id=".$callback_query_id."&text=".$text."&show_alert=".$show_alert);
}

if (isset($data['callback_query'])) {
  send_answerCallbackQuery($token, $data['callback_query']['id'], "проверка ", false);
}

So everything works

J
jnas, 2017-11-19
@jnas

Similarly, I want to make an alert message
via GetUpdate, it doesn’t work, the webhook is installed,
I don’t quite understand what needs to be specified in the callback_query_id field
, before I received a response when I clicked the inline button
then I make a request
I get the same error as you. I don't quite understand how to use this feature.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question