Bot menu button

Bots can choose the behavior of the menu button shown next to the text input field.

For a simplified description using the HTTP bot API, see here ยป.

Setting the menu button

Schema:

botMenuButtonDefault#7533a588 = BotMenuButton;
botMenuButtonCommands#4258c205 = BotMenuButton;
botMenuButton#c7b57ce6 text:string url:string = BotMenuButton;

inputUserEmpty#b98886cf = InputUser;
inputUser#f21158c6 user_id:long access_hash:long = InputUser;

---functions---

bots.setBotMenuButton#4504d54f user_id:InputUser button:BotMenuButton = Bool;

Bots can use bots.setBotMenuButton to change the menu button for a certain user, or for all users.

Set scope: all users

To change the menu button for all users use the following parameters:

botMenuButtonDefault shouldn't be used as it has no effect, keeping the previously set menu button (either botMenuButton or botMenuButtonCommands).

Set scope: specific users

To change the menu button for a specific user use the following parameters:

Getting the menu button

Bots

botMenuButtonDefault#7533a588 = BotMenuButton;
botMenuButtonCommands#4258c205 = BotMenuButton;
botMenuButton#c7b57ce6 text:string url:string = BotMenuButton;

inputUserEmpty#b98886cf = InputUser;
inputUser#f21158c6 user_id:long access_hash:long = InputUser;

---functions---

bots.getBotMenuButton#9c60eb28 user_id:InputUser = BotMenuButton;

Bots might need to know the button type currently used in a given chat or in all chats: bots.getBotMenuButton can be used for this.

Users can't use this method, and should use the user method instead.

Get scope: all users

To get the menu button used for all users use the following parameter:

One of the following constructors will be returned:

botMenuButtonDefault will never be returned in this case.

Get scope: specific users

To get the menu button used for a specific user use the following parameter:

  • user_id - inputUser with the user ID access/hash

One of the following constructors will be returned:

Users

updateBotMenuButton#14b85813 bot_id:long button:BotMenuButton = Update;

botMenuButtonCommands#4258c205 = BotMenuButton;
botMenuButton#c7b57ce6 text:string url:string = BotMenuButton;

botInfo#8f300b57 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector<BotCommand> menu_button:flags.3?BotMenuButton = BotInfo;

userFull#cc997720 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights premium_gifts:flags.19?Vector<PremiumGiftOption> wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int = UserFull;

---functions---

users.getFullUser#b60f5918 id:InputUser = users.UserFull;

Users will receive an updateBotMenuButton update when a bot changes the behavior of the menu button globally or in the private chat with the user.

For new bots, users.getFullUser can be used to fetch the userFull related to the bot, containing the botInfo constructor with various info about the bot, including the menu button behavior.

botMenuButtonDefault will never be returned in a updateBotMenuButton or in a botInfo (but if it does happen, treat it like a botMenuButtonCommands).

Bots should use the bot method instead.