telegram-crawler/data/web/blogfork.telegram.org/api/bots/menu.html
2024-08-02 00:44:36 +00:00

212 lines
15 KiB
HTML

<!DOCTYPE html>
<html class="">
<head>
<meta charset="utf-8">
<title>Bot menu button</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="description" content="Bots can choose the behavior of the menu button shown next to the text input field.">
<meta property="og:title" content="Bot menu button">
<meta property="og:image" content="">
<meta property="og:description" content="Bots can choose the behavior of the menu button shown next to the text input field.">
<link rel="icon" type="image/svg+xml" href="/img/website_icon.svg?4">
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png">
<link rel="alternate icon" href="/img/favicon.ico" type="image/x-icon" />
<link href="/css/bootstrap.min.css?3" rel="stylesheet">
<link href="/css/telegram.css?240" rel="stylesheet" media="screen">
<style>
</style>
</head>
<body class="preload">
<div class="dev_page_wrap">
<div class="dev_page_head navbar navbar-static-top navbar-tg">
<div class="navbar-inner">
<div class="container clearfix">
<ul class="nav navbar-nav navbar-right hidden-xs"><li class="navbar-twitter"><a href="https://twitter.com/telegram" target="_blank" data-track="Follow/Twitter" onclick="trackDlClick(this, event)"><i class="icon icon-twitter"></i><span> Twitter</span></a></li></ul>
<ul class="nav navbar-nav">
<li><a href="//telegram.org/">Home</a></li>
<li class="hidden-xs"><a href="//telegram.org/faq">FAQ</a></li>
<li class="hidden-xs"><a href="//telegram.org/apps">Apps</a></li>
<li class="active"><a href="/api">API</a></li>
<li class=""><a href="/mtproto">Protocol</a></li>
<li class=""><a href="/schema">Schema</a></li>
</ul>
</div>
</div>
</div>
<div class="container clearfix">
<div class="dev_page">
<div id="dev_page_content_wrap" class=" ">
<div class="dev_page_bread_crumbs"><ul class="breadcrumb clearfix"><li><a href="/api" >API</a></li><i class="icon icon-breadcrumb-divider"></i><li><a href="/api/bots%2Fmenu" >Bot menu button</a></li></ul></div>
<h1 id="dev_page_title">Bot menu button</h1>
<div id="dev_page_content"><!-- scroll_nav -->
<p>Bots can choose the behavior of the menu button shown next to the text input field. </p>
<p>For a simplified description using the HTTP bot API, see <a href="/bots/api">here »</a>. </p>
<h3><a class="anchor" href="#setting-the-menu-button" id="setting-the-menu-button" name="setting-the-menu-button"><i class="anchor-icon"></i></a>Setting the menu button</h3>
<p>Schema:</p>
<pre><code><a href='/constructor/botMenuButtonDefault'>botMenuButtonDefault</a>#7533a588 = <a href='/type/BotMenuButton'>BotMenuButton</a>;
<a href='/constructor/botMenuButtonCommands'>botMenuButtonCommands</a>#4258c205 = <a href='/type/BotMenuButton'>BotMenuButton</a>;
<a href='/constructor/botMenuButton'>botMenuButton</a>#c7b57ce6 text:<a href='/type/string'>string</a> url:<a href='/type/string'>string</a> = <a href='/type/BotMenuButton'>BotMenuButton</a>;
<a href='/constructor/inputUserEmpty'>inputUserEmpty</a>#b98886cf = <a href='/type/InputUser'>InputUser</a>;
<a href='/constructor/inputUser'>inputUser</a>#f21158c6 user_id:<a href='/type/long'>long</a> access_hash:<a href='/type/long'>long</a> = <a href='/type/InputUser'>InputUser</a>;
---functions---
<a href='/method/bots.setBotMenuButton'>bots.setBotMenuButton</a>#4504d54f user_id:<a href='/type/InputUser'>InputUser</a> button:<a href='/type/BotMenuButton'>BotMenuButton</a> = <a href='/type/Bool'>Bool</a>;</code></pre>
<p>Bots can use <a href="/method/bots.setBotMenuButton">bots.setBotMenuButton</a> to change the menu button for a certain user, or for all users.</p>
<h4><a class="anchor" href="#set-scope-all-users" id="set-scope-all-users" name="set-scope-all-users"><i class="anchor-icon"></i></a>Set scope: all users</h4>
<p>To change the menu button for all users use the following parameters:</p>
<ul>
<li><code>user_id</code> - <a href="/constructor/inputUserEmpty">inputUserEmpty</a></li>
<li><code>button</code> - one of the following constructors:<ul>
<li><a href="/constructor/botMenuButton">botMenuButton</a> - Opens a <a href="/api/bots/webapps">bot mini app</a> when clicked.</li>
<li><a href="/constructor/botMenuButtonCommands">botMenuButtonCommands</a> - Opens the bot's command list when clicked.</li>
</ul>
</li>
</ul>
<p><a href="/constructor/botMenuButton">botMenuButtonDefault</a> shouldn't be used as it has no effect, keeping the previously set menu button (either <a href="/constructor/botMenuButton">botMenuButton</a> or <a href="/constructor/botMenuButtonCommands">botMenuButtonCommands</a>).</p>
<h4><a class="anchor" href="#set-scope-specific-users" id="set-scope-specific-users" name="set-scope-specific-users"><i class="anchor-icon"></i></a>Set scope: specific users</h4>
<p>To change the menu button for a specific user use the following parameters:</p>
<ul>
<li><code>user_id</code> - <a href="/constructor/inputUser">inputUser</a> with the user ID/access hash</li>
<li><code>button</code> - one of the following constructors:<ul>
<li><a href="/constructor/botMenuButton">botMenuButton</a> - Opens a <a href="/api/bots/webapps">bot mini app</a> when clicked.</li>
<li><a href="/constructor/botMenuButtonCommands">botMenuButtonCommands</a> - Opens the bot's command list when clicked.</li>
<li><a href="/constructor/botMenuButton">botMenuButtonDefault</a> - Resets the behavior of the button to the <a href="#set-scope-all-users">default scope (all users)</a>. </li>
</ul>
</li>
</ul>
<h3><a class="anchor" href="#getting-the-menu-button" id="getting-the-menu-button" name="getting-the-menu-button"><i class="anchor-icon"></i></a>Getting the menu button</h3>
<h4><a class="anchor" href="#bots" id="bots" name="bots"><i class="anchor-icon"></i></a>Bots</h4>
<pre><code><a href='/constructor/botMenuButtonDefault'>botMenuButtonDefault</a>#7533a588 = <a href='/type/BotMenuButton'>BotMenuButton</a>;
<a href='/constructor/botMenuButtonCommands'>botMenuButtonCommands</a>#4258c205 = <a href='/type/BotMenuButton'>BotMenuButton</a>;
<a href='/constructor/botMenuButton'>botMenuButton</a>#c7b57ce6 text:<a href='/type/string'>string</a> url:<a href='/type/string'>string</a> = <a href='/type/BotMenuButton'>BotMenuButton</a>;
<a href='/constructor/inputUserEmpty'>inputUserEmpty</a>#b98886cf = <a href='/type/InputUser'>InputUser</a>;
<a href='/constructor/inputUser'>inputUser</a>#f21158c6 user_id:<a href='/type/long'>long</a> access_hash:<a href='/type/long'>long</a> = <a href='/type/InputUser'>InputUser</a>;
---functions---
<a href='/method/bots.getBotMenuButton'>bots.getBotMenuButton</a>#9c60eb28 user_id:<a href='/type/InputUser'>InputUser</a> = <a href='/type/BotMenuButton'>BotMenuButton</a>;</code></pre>
<p>Bots might need to know the button type currently used in a given chat or in all chats: <a href="/method/bots.getBotMenuButton">bots.getBotMenuButton</a> can be used for this.</p>
<p>Users can't use this method, and should use the <a href="#users">user</a> method instead. </p>
<h5><a class="anchor" href="#get-scope-all-users" id="get-scope-all-users" name="get-scope-all-users"><i class="anchor-icon"></i></a>Get scope: all users</h5>
<p>To get the menu button used for all users use the following parameter:</p>
<ul>
<li><code>user_id</code> - <a href="/constructor/inputUserEmpty">inputUserEmpty</a></li>
</ul>
<p>One of the following constructors will be returned:</p>
<ul>
<li><a href="/constructor/botMenuButton">botMenuButton</a> - Opens a <a href="/api/bots/webapps">bot mini app</a> when clicked.</li>
<li><a href="/constructor/botMenuButtonCommands">botMenuButtonCommands</a> - Opens the bot's command list when clicked.</li>
</ul>
<p><a href="/constructor/botMenuButton">botMenuButtonDefault</a> will never be returned in this case.</p>
<h5><a class="anchor" href="#get-scope-specific-users" id="get-scope-specific-users" name="get-scope-specific-users"><i class="anchor-icon"></i></a>Get scope: specific users</h5>
<p>To get the menu button used for a specific user use the following parameter:</p>
<ul>
<li><code>user_id</code> - <a href="/constructor/inputUser">inputUser</a> with the user ID access/hash</li>
</ul>
<p>One of the following constructors will be returned:</p>
<ul>
<li><a href="/constructor/botMenuButton">botMenuButton</a> - Opens a <a href="/api/bots/webapps">bot mini app</a> when clicked.</li>
<li><a href="/constructor/botMenuButtonCommands">botMenuButtonCommands</a> - Opens the bot's command list when clicked.</li>
<li><a href="/constructor/botMenuButton">botMenuButtonDefault</a> - The <a href="#get-scope-all-users">default scope (all users) button behavior is in use</a>. </li>
</ul>
<h4><a class="anchor" href="#users" id="users" name="users"><i class="anchor-icon"></i></a>Users</h4>
<pre><code><a href='/constructor/updateBotMenuButton'>updateBotMenuButton</a>#14b85813 bot_id:<a href='/type/long'>long</a> button:<a href='/type/BotMenuButton'>BotMenuButton</a> = <a href='/type/Update'>Update</a>;
<a href='/constructor/botMenuButtonCommands'>botMenuButtonCommands</a>#4258c205 = <a href='/type/BotMenuButton'>BotMenuButton</a>;
<a href='/constructor/botMenuButton'>botMenuButton</a>#c7b57ce6 text:<a href='/type/string'>string</a> url:<a href='/type/string'>string</a> = <a href='/type/BotMenuButton'>BotMenuButton</a>;
<a href='/constructor/botInfo'>botInfo</a>#8f300b57 flags:<a href='/type/%23'>#</a> user_id:flags.0?<a href='/type/long'>long</a> description:flags.1?<a href='/type/string'>string</a> description_photo:flags.4?<a href='/type/Photo'>Photo</a> description_document:flags.5?<a href='/type/Document'>Document</a> commands:flags.2?<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/BotCommand'>BotCommand</a>&gt; menu_button:flags.3?<a href='/type/BotMenuButton'>BotMenuButton</a> = <a href='/type/BotInfo'>BotInfo</a>;
<a href='/constructor/userFull'>userFull</a>#b9b12c6c flags:<a href='/type/%23'>#</a> blocked:flags.0?<a href='/constructor/true'>true</a> phone_calls_available:flags.4?<a href='/constructor/true'>true</a> phone_calls_private:flags.5?<a href='/constructor/true'>true</a> can_pin_message:flags.7?<a href='/constructor/true'>true</a> has_scheduled:flags.12?<a href='/constructor/true'>true</a> video_calls_available:flags.13?<a href='/constructor/true'>true</a> voice_messages_forbidden:flags.20?<a href='/constructor/true'>true</a> translations_disabled:flags.23?<a href='/constructor/true'>true</a> stories_pinned_available:flags.26?<a href='/constructor/true'>true</a> blocked_my_stories_from:flags.27?<a href='/constructor/true'>true</a> wallpaper_overridden:flags.28?<a href='/constructor/true'>true</a> id:<a href='/type/long'>long</a> about:flags.1?<a href='/type/string'>string</a> settings:<a href='/type/PeerSettings'>PeerSettings</a> personal_photo:flags.21?<a href='/type/Photo'>Photo</a> profile_photo:flags.2?<a href='/type/Photo'>Photo</a> fallback_photo:flags.22?<a href='/type/Photo'>Photo</a> notify_settings:<a href='/type/PeerNotifySettings'>PeerNotifySettings</a> bot_info:flags.3?<a href='/type/BotInfo'>BotInfo</a> pinned_msg_id:flags.6?<a href='/type/int'>int</a> common_chats_count:<a href='/type/int'>int</a> folder_id:flags.11?<a href='/type/int'>int</a> ttl_period:flags.14?<a href='/type/int'>int</a> theme_emoticon:flags.15?<a href='/type/string'>string</a> private_forward_name:flags.16?<a href='/type/string'>string</a> bot_group_admin_rights:flags.17?<a href='/type/ChatAdminRights'>ChatAdminRights</a> bot_broadcast_admin_rights:flags.18?<a href='/type/ChatAdminRights'>ChatAdminRights</a> premium_gifts:flags.19?<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/PremiumGiftOption'>PremiumGiftOption</a>&gt; wallpaper:flags.24?<a href='/type/WallPaper'>WallPaper</a> stories:flags.25?<a href='/type/PeerStories'>PeerStories</a> = <a href='/type/UserFull'>UserFull</a>;
---functions---
<a href='/method/users.getFullUser'>users.getFullUser</a>#b60f5918 id:<a href='/type/InputUser'>InputUser</a> = <a href='/type/users.UserFull'>users.UserFull</a>;</code></pre>
<p>Users will receive an <a href="/constructor/updateBotMenuButton">updateBotMenuButton</a> update when a bot changes the behavior of the menu button globally or in the private chat with the user. </p>
<p>For new bots, <a href="/method/users.getFullUser">users.getFullUser</a> can be used to fetch the <a href="/constructor/userFull">userFull</a> related to the bot, containing the <a href="/constructor/botInfo">botInfo</a> constructor with various info about the bot, including the menu button behavior. </p>
<p><a href="/constructor/botMenuButton">botMenuButtonDefault</a> will never be returned in a <a href="/constructor/updateBotMenuButton">updateBotMenuButton</a> or in a <a href="/constructor/botInfo">botInfo</a> (but if it does happen, treat it like a <a href="/constructor/botMenuButtonCommands">botMenuButtonCommands</a>).</p>
<p>Bots should use the <a href="#bots">bot</a> method instead.</p></div>
</div>
</div>
</div>
<div class="footer_wrap">
<div class="footer_columns_wrap footer_desktop">
<div class="footer_column footer_column_telegram">
<h5>Telegram</h5>
<div class="footer_telegram_description"></div>
Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.
</div>
<div class="footer_column">
<h5><a href="//telegram.org/faq">About</a></h5>
<ul>
<li><a href="//telegram.org/faq">FAQ</a></li>
<li><a href="//telegram.org/privacy">Privacy</a></li>
<li><a href="//telegram.org/press">Press</a></li>
</ul>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps#mobile-apps">Mobile Apps</a></h5>
<ul>
<li><a href="//telegram.org/dl/ios">iPhone/iPad</a></li>
<li><a href="//telegram.org/android">Android</a></li>
<li><a href="//telegram.org/dl/web">Mobile Web</a></li>
</ul>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps#desktop-apps">Desktop Apps</a></h5>
<ul>
<li><a href="//desktop.telegram.org/">PC/Mac/Linux</a></li>
<li><a href="//macos.telegram.org/">macOS</a></li>
<li><a href="//telegram.org/dl/web">Web-browser</a></li>
</ul>
</div>
<div class="footer_column footer_column_platform">
<h5><a href="/">Platform</a></h5>
<ul>
<li><a href="/api">API</a></li>
<li><a href="//translations.telegram.org/">Translations</a></li>
<li><a href="//instantview.telegram.org/">Instant View</a></li>
</ul>
</div>
</div>
<div class="footer_columns_wrap footer_mobile">
<div class="footer_column">
<h5><a href="//telegram.org/faq">About</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/blog">Blog</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps">Apps</a></h5>
</div>
<div class="footer_column">
<h5><a href="/">Platform</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/press">Press</a></h5>
</div>
</div>
</div>
</div>
<script src="/js/main.js?47"></script>
<script src="/js/jquery.min.js?1"></script>
<script src="/js/bootstrap.min.js?1"></script>
<script>window.initDevPageNav&&initDevPageNav();
backToTopInit("Go up");
removePreloadInit();
</script>
</body>
</html>