telegram.KeyboardButton

class telegram.KeyboardButton(text, request_contact=None, request_location=None, **kwargs)

Bases: telegram.base.TelegramObject

This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button.

Note

Optional fields are mutually exclusive.

text

str – Text of the button.

request_contact

bool – Optional. If the user’s phone number will be sent.

request_location

bool – Optional. If the user’s current location will be sent.

Parameters:
  • text (str) – Text of the button. If none of the optional fields are used, it will be sent to the bot as a message when the button is pressed.
  • request_contact (bool, optional) – If True, the user’s phone number will be sent as a contact when the button is pressed. Available in private chats only.
  • request_location (bool, optional) – If True, the user’s current location will be sent when the button is pressed. Available in private chats only.

Note

request_contact and request_location options will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.