Telegram bot api keyboard

I have a problem with Telegram Bot Api and with "ReplyKeyboard". I am using Python 2.7 and posting a message:

TelegramAPI.post(TELEGRAM_URL + "sendMessage", data=dict(chat_id=CHAT_ID, text="", keyboard={'keyboard': keyboard, 'one_time_keyboard': False, 'resize_keyboard': True}) 

in this format:

 [["A button"], ["B button"]] 

But in Telegram I do not see the keyboard. What could be the problem?

+5
source share
1 answer

According to the API API documentation for the user keyboard, the reply_markup parameter is reply_markup , the value of which is the JSON keyboard specification for the keyboard. Assuming your TelegramAPI.post() function is not intended for JSON serialization, I would try the following:

 import json json_keyboard = json.dumps({'keyboard': [["A button"], ["B button"]], 'one_time_keyboard': False, 'resize_keyboard': True}) TelegramAPI.post(TELEGRAM_URL + "sendMessage", data=dict(chat_id=CHAT_ID, text="Has to be non-empty", reply_markup=json_keyboard)) 

Note that text must be non-empty.

+3
source

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


All Articles