Troubleshooting Reply Keyboard in Telegram Bot API

I’m facing an issue with the Reply Keyboard feature in the Telegram Bot API using Python 2.7. I issue a POST request to send a message, but the custom keyboard is not showing up in the Telegram app. Below is a sample implementation:

bot_client.make_request(BOT_SERVER + 'messageSend', payload={
    'user_id': USER_REF,
    'content': '',
    'keyboard_config': {
        'layout': button_grid,
        'single_use': False,
        'auto_adjust': True
    }
})

And the keyboard layout is defined as follows:

[['Opt 1'], ['Opt 2']]

Please let me know what might be causing this issue.

After working on similar setups, I found that the issue might be related to using the incorrect parameter name for formatting keyboards. The Telegram Bot API typically expects the custom keyboard layout to be provided under the key ‘reply_markup’. In addition, since you are using Python 2.7, verifying that the keyboard layout is correctly JSON encoded as a string is crucial. Adjusting these details resolved the issue in my case; double-check if your payload formatting aligns with the official documentation and try retesting.

It appears that the issue may be due to a mismatch in the device formatting of the payload rather than a problem with the API itself. I encountered a similar problem when developing my own bot. I eventually discovered that Telegram expects the keyboard configuration to be embedded within a specific parameter as a JSON string. This means verifying that the custom keyboard configuration is properly formatted and assigned to the correct field when sending the request. Ensuring that all keys and data types conform to the latest documentation can often resolve such issues.

hey, try json.dumps-ing your keyboard config; i had a similar issue where the api didnt pick up raw python lists. check if its converting correctly to a json string before sending. might solve the keybord display problm.