I have a message to which I want to add an inline button. When clicking this button the user can forward 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)
]);
There is a solution that i can think of. Aaccording to Telegram API documentation, you can pass an optional parameter called switch_inline_query
. This is not the application of 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)
]);
Pressing the inline button will prompt the user to select one of their groups or chats, open that chat and insert the bot‘s username and the specified message:@Yourbot This is a message
and by pressing send button message will be sent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With