Answer the question
In order to leave comments, you need to log in
How to make buttons under the chat in a telegram bot?
I can’t figure out how to make buttons under the chat in the bot, I didn’t find the necessary information. You need to make buttons (at least one) as in the screenshot: I
wrote the code for the command so that when it is entered, a button under the chat pops up, which can be pressed
Function for the button that returns json:
function reply_keyboard($array) {
return json_encode(['reply_keyboard' => $array]); }
if (strpos($message, "/start") === 0) { // Команда /start
$cocktails_button = [];
$reply_markup = reply_keyboard($cocktails_button);
}
Answer the question
In order to leave comments, you need to log in
For starters, I made a function that returns json
function reply_keyboard($array) {
return json_encode(['keyboard' => $array]);
}
if (strpos($message, "/start") === 0) { // Команда /start, вызов кнопки под чатом
$post = [
'chat_id' => $chat_id,
'text' => 'Напиши любое сообщение или нажми на кнопку ниже, чтобы начать!',
$cocktails_button = [],
'reply_markup' => reply_keyboard($cocktails_button),
'resize_keyboard' => true,
'one_time_keyboard' => true
];
sendRequest('sendMessage', $post);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question