I can send message, sample:
https://api.telegram.org/bot[TOKEN]/sendMessage?chat_id=@[USERNAME]&text=hello
but I want to send message with inline buttons, please help.
I can send message, sample:
https://api.telegram.org/bot[TOKEN]/sendMessage?chat_id=@[USERNAME]&text=hello
but I want to send message with inline buttons, please help.
This would be the url you are looking for:
https://api.telegram.org/bot[TOKEN]/sendMessage?chat_id=[CHAT_ID]&text=[TEXT]&reply_markup={"inline_keyboard": [[{"text": "hi", "callback_data": "hi"}]]}
You can pass a JSON toreply_markup
field. Here this our JSON:
{
"inline_keyboard": [
[
{
"text": "hi",
"callback_data": "hi"
}
]
]
}
I suggest you use an API library to communicate with Telegram. Using bare urls has its own challenges, like sometimes you should url encode your JSON to avoid errors in URL.
For example this is the url-encoded version of above JSON:
%7B%22inline_keyboard%22%3A%20%5B%5B%7B%22text%22%3A%20%22hi%22%2C%20%22callback_data%22%3A%20%22hi%22%7D%5D%5D%7D