How to create a built-in button for php telegram bot messaging

I have a message to which I want to add a built-in button. By clicking this button, the user can redirect this message to groups. How can i do this?

$keyboard = [
    'inline_keyboard' => [
    [['text' => 'forward me to groups']],
]];
HTTPRequest("sendMessage", [
    "chat_id" => $request["message"]["chat"]["id"],
    "text" => "this is a message",
    "reply_markup" => json_encode($keyboard)
]);
+4
source share
1 answer

There is a solution that I can think of. According to the Telegram API Documentation , you can pass an optional parameter switch_inline_query. This is not an application switch_inline_query, but it can do what you want. Your code will be like this:

$keyboard = [
'inline_keyboard' => [
[['text' => 'forward me to groups'], 'switch_inline_query' => 'this is a message'],
]];
HTTPRequest("sendMessage", [
    "chat_id" => $request["message"]["chat"]["id"],
    "text" => "this is a message",
    "reply_markup" => json_encode($keyboard)
]);

inline , :
@Yourbot This is a message
.

+2

Source: https://habr.com/ru/post/1661881/


All Articles