<divclass="dev_page_bread_crumbs"><ulclass="breadcrumb clearfix"><li><ahref="/api">API</a></li><iclass="icon icon-breadcrumb-divider"></i><li><ahref="/api/bots%2Fmenu">Bot menu button</a></li></ul></div>
<h1id="dev_page_title">Bot menu button</h1>
<divid="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 <ahref="/bots/api">here »</a>. </p>
<h3><aclass="anchor"href="#setting-the-menu-button"id="setting-the-menu-button"name="setting-the-menu-button"><iclass="anchor-icon"></i></a>Setting the menu button</h3>
<p>Bots can use <ahref="/method/bots.setBotMenuButton">bots.setBotMenuButton</a> to change the menu button for a certain user, or for all users.</p>
<h4><aclass="anchor"href="#set-scope-all-users"id="set-scope-all-users"name="set-scope-all-users"><iclass="anchor-icon"></i></a>Set scope: all users</h4>
<p>To change the menu button for all users use the following parameters:</p>
<li><code>button</code> - one of the following constructors:<ul>
<li><ahref="/constructor/botMenuButton">botMenuButton</a> - Opens a <ahref="/api/bots/webapps">bot web app</a> when clicked.</li>
<li><ahref="/constructor/botMenuButtonCommands">botMenuButtonCommands</a> - Opens the bot's command list when clicked.</li>
</ul>
</li>
</ul>
<p><ahref="/constructor/botMenuButton">botMenuButtonDefault</a> shouldn't be used as it has no effect, keeping the previously set menu button (either <ahref="/constructor/botMenuButton">botMenuButton</a> or <ahref="/constructor/botMenuButtonCommands">botMenuButtonCommands</a>).</p>
<h4><aclass="anchor"href="#set-scope-specific-users"id="set-scope-specific-users"name="set-scope-specific-users"><iclass="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> - <ahref="/constructor/inputUser">inputUser</a> with the user ID/access hash</li>
<li><code>button</code> - one of the following constructors:<ul>
<li><ahref="/constructor/botMenuButton">botMenuButton</a> - Opens a <ahref="/api/bots/webapps">bot web app</a> when clicked.</li>
<li><ahref="/constructor/botMenuButtonCommands">botMenuButtonCommands</a> - Opens the bot's command list when clicked.</li>
<li><ahref="/constructor/botMenuButton">botMenuButtonDefault</a> - Resets the behavior of the button to the <ahref="#set-scope-all-users">default scope (all users)</a>. </li>
</ul>
</li>
</ul>
<h3><aclass="anchor"href="#getting-the-menu-button"id="getting-the-menu-button"name="getting-the-menu-button"><iclass="anchor-icon"></i></a>Getting the menu button</h3>
<p>Bots might need to know the button type currently used in a given chat or in all chats: <ahref="/method/bots.getBotMenuButton">bots.getBotMenuButton</a> can be used for this.</p>
<p>Users can't use this method, and should use the <ahref="#users">user</a> method instead. </p>
<h5><aclass="anchor"href="#get-scope-all-users"id="get-scope-all-users"name="get-scope-all-users"><iclass="anchor-icon"></i></a>Get scope: all users</h5>
<p>To get the menu button used for all users use the following parameter:</p>
<p>One of the following constructors will be returned:</p>
<ul>
<li><ahref="/constructor/botMenuButton">botMenuButton</a> - Opens a <ahref="/api/bots/webapps">bot web app</a> when clicked.</li>
<li><ahref="/constructor/botMenuButtonCommands">botMenuButtonCommands</a> - Opens the bot's command list when clicked.</li>
</ul>
<p><ahref="/constructor/botMenuButton">botMenuButtonDefault</a> will never be returned in this case.</p>
<h5><aclass="anchor"href="#get-scope-specific-users"id="get-scope-specific-users"name="get-scope-specific-users"><iclass="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> - <ahref="/constructor/inputUser">inputUser</a> with the user ID access/hash</li>
</ul>
<p>One of the following constructors will be returned:</p>
<ul>
<li><ahref="/constructor/botMenuButton">botMenuButton</a> - Opens a <ahref="/api/bots/webapps">bot web app</a> when clicked.</li>
<li><ahref="/constructor/botMenuButtonCommands">botMenuButtonCommands</a> - Opens the bot's command list when clicked.</li>
<li><ahref="/constructor/botMenuButton">botMenuButtonDefault</a> - The <ahref="#get-scope-all-users">default scope (all users) button behavior is in use</a>. </li>
<p>Users will receive an <ahref="/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, <ahref="/method/users.getFullUser">users.getFullUser</a> can be used to fetch the <ahref="/constructor/userFull">userFull</a> related to the bot, containing the <ahref="/constructor/botInfo">botInfo</a> constructor with various info about the bot, including the menu button behavior. </p>
<p><ahref="/constructor/botMenuButton">botMenuButtonDefault</a> will never be returned in a <ahref="/constructor/updateBotMenuButton">updateBotMenuButton</a> or in a <ahref="/constructor/botInfo">botInfo</a> (but if it does happen, treat it like a <ahref="/constructor/botMenuButtonCommands">botMenuButtonCommands</a>).</p>