Search code examples
pythontelegramsoft-keyboardpython-telegram-bot

Can Telegram client interact with mobile onscreen keyboard?


I write Telegram bot in Python using the python-telegram-bot wrapper. In some cases I need input from the user (plain text, only numbers).

Is it possible to specify the mobile Telegram client that I need a certain type of on-screen keyboard, similar to the way the keyboard responds to the input fields for the phone, URL, email etc. ?

When I use bot.sendMessage() method I can only set and unset my custom keyboards with ReplyKeyboardRemove, but I see no way to specify type of on-screen keyboard.


Solution

  • After some research I found out that this is very probably not possible. Telegram bots can interact with on-screen keyboard only with ForceReply method which can tell client to display a reply interface to the user (act as if the user has selected the bot‘s message and tapped ’Reply') and ReplyKeyboardRemove that can hide reply interface, but I see no way to specify the type of soft keyboard on mobile devices, unfortunately.

    However, if you find a way to do it - I will be very appreciate if you write it as an answer.