A
A
Artur Galyaev2018-08-21 17:17:20
JSON
Artur Galyaev, 2018-08-21 17:17:20

How to set up inline buttons in Telegram via JSON?

There is such JSON code with which you can implement inline buttons
here:

{
"chat_id":"чат айди",
"text":"Текст",
"reply_markup": {
    "inline_keyboard": [
    [{
  "text": "",
  "callback_data":"art"

     }]
]
}
}

Question: how to make the bot send a message when the button is clicked?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
body9, 2018-08-21
@body9

When sending this json, the user will receive a message and a button. In this json you are passing a parameter "callback_data"with value "art". When the user clicks on the button, you will receive an update response from Telegram on the server (see documentation https://core.telegram.org/bots/api#update ). There is a parameter callback_query, and in it data. This parameter will contain your value "art"that you passed. That is, you are just waiting for a response from the telegram that will come to your address (attached by setWebhook). And if data = "art", then you do what the button was for - form a message from the bot, for example

{
"chat_id":"чат айди",
"text":"Текст-ответ на кнопку",
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question