Answer the question
In order to leave comments, you need to log in
How to add buttons to Telegram bot in Python?
How to add a button in a normal request via requests
requests.post(' https://api.telegram.org/bot "token"/sendMessage?chat_id="chatid"&KeyboardButton&text=1111')
this way doesn't work, sends just text, without creating a button
Answer the question
In order to leave comments, you need to log in
Only keyboards can be sent to the server (Inlinekeyboard, replykeyboard and it seems like there are other types), also the keyboard must be a list object converted to json and added to the reply_markup field
import requests
import json
token = <Ваш токен>
URL = 'https://api.telegram.org/bot' + token
r1 = requests.get(URL + '/getUpdates').json()
chat_id = r1['result'][-1]['message']['from']['id']
reply_markup = {
'inline_keyboard': }
data = {'chat_id': chat_id, 'text': 'текст', 'reply_markup': json.dumps(reply_markup)}
r2 = requests.post(URL + '/sendMessage', data=data)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question