<divclass="dev_page_bread_crumbs"><ulclass="breadcrumb clearfix"><li><ahref="/api">API</a></li><iclass="icon icon-breadcrumb-divider"></i><li><ahref="/api/bots%2Fattach">Bot attachment menu and side menu entries</a></li></ul></div>
<h1id="dev_page_title">Bot attachment menu and side menu entries</h1>
<p>Bots can install attachment menu and side menu entries, offering conveniently accessible, versatile <ahref="/api/bots/webapps#attachment-menu-mini-apps">mini apps</a>.</p>
<p>Bots that have the <code>bot_attach_menu</code> flag set offer an attachment or side menu entry that can be added to the in-app attachment menu or main view side menu. </p>
<p>Use <ahref="/method/messages.getAttachMenuBot">messages.getAttachMenuBot</a> to get info about the attachment/side menu entry of a given bot, see the <ahref="/constructor/attachMenuBot">attachMenuBot constructor page for more info »</a>. </p>
<p>The currently installed attachment/side menu list can be fetched using <ahref="/method/messages.getAttachMenuBots">messages.getAttachMenuBots</a>. </p>
<p>Use <ahref="/method/messages.toggleBotInAttachMenu">messages.toggleBotInAttachMenu</a> to enable or disable the attachment and/or side menu of a given bot (the entries that must be installed or uninstalled depend on the values of the <ahref="/constructor/attachMenuBot">attachMenuBot</a>.<code>show_in_attach_menu</code> and <ahref="/constructor/attachMenuBot">attachMenuBot</a>.<code>show_in_side_menu</code> flags).<br>
Changes made using this method will trigger an <ahref="/constructor/updateAttachMenuBots">updateAttachMenuBots</a> update in other clients, which should trigger a <ahref="/method/messages.getAttachMenuBots">messages.getAttachMenuBots</a> call to fetch the full updated list of installed attachment/side menu entries.<br>
The attachment/side menu list should also be refreshed if the user changes the app's language in the settings. </p>
<p>Once an attachment/side menu is enabled for a certain user, the <ahref="/constructor/user">user</a>.<code>attach_menu_enabled</code> flag will be set <em>for the bot</em>, and the <ahref="/constructor/attachMenuBot">attachMenuBot</a>.<code>inactive</code> flag will be unset. </p>
<p>Clicking on the attachment/side menu entry should open the related <ahref="/api/bots/webapps#attachment-menu-mini-apps">attachment menu mini app</a>, see <ahref="/api/bots/webapps#attachment-menu-mini-apps">here »</a> and <ahref="/api/bots/webapps#side-menu-mini-apps">here »</a> for more info on the required steps.</p>
<p>Attachment menus can be installed and opened through <ahref="/api/links#bot-attachment-or-side-menu-links">attachment/side menu deep links</a> and through <ahref="/api/links#mini-app-links">mini app links</a>.</p>
<p>In particular, when clicking on such a link, <ahref="/method/messages.getAttachMenuBot">messages.getAttachMenuBot</a> should be invoked to check if the bot has an associated attachment/side menu entry, and if yes: </p>
<ul>
<li>If the <ahref="/constructor/attachMenuBot">attachMenuBot</a>.<code>inactive</code> flag:<ul>
<li>...is set, the attachment/side menu entry is not installed.<br>
Thus, before launching the mini app when clicking on a <ahref="/api/links#bot-attachment-or-side-menu-links">attachment/side menu deep link</a>, the client should show a prompt to the user, asking to add the mini app to the attachment/side menu.<br>
Note that if the <ahref="/constructor/attachMenuBot">attachMenuBot</a>.<code>side_menu_disclaimer_needed</code> flag is set, an additional mandatory checkbox to accept the <ahref="https://telegram.org/tos/mini-apps">mini apps TOS</a> and a disclaimer indicating that this Mini App is not affiliated to Telegram should be shown in the installation prompt.<br>
If the user accepts, invoke <ahref="/method/messages.toggleBotInAttachMenu">messages.toggleBotInAttachMenu</a> with the <code>write_allowed</code> flag set and proceed to the next step, otherwise abort the process. </li>
<li>...is not set, and the <ahref="/constructor/attachMenuBot">attachMenuBot</a>.<code>side_menu_disclaimer_needed</code> flag is still set, an additional mandatory checkbox to accept the <ahref="https://telegram.org/tos/mini-apps">mini apps TOS</a> and a disclaimer indicating that this Mini App is not affiliated to Telegram should be shown.<br>
If the user accepts, proceed to the next step, otherwise abort the process. </li>
</ul>
</li>
<li>Open the Mini App:<ul>
<li>If the link is a <ahref="/api/links#direct-mini-app-links">direct mini app link</a>, open the Mini App regardless of the currently open Telegram chat (in fact, the Mini App should opened even if the client itself is minimized), as specified <ahref="/api/bots/webapps#direct-link-mini-apps">here »</a>. </li>
<li>For <ahref="/api/links#bot-attachment-or-side-menu-links">attachment/side menu links</a>, check that the attachment menu can be opened in the chosen chat type by checking the <ahref="/constructor/attachMenuBot">attachMenuBot</a>.<code>peer_types</code> field. <ul>
<li>If the chosen chat is supported, open the <ahref="/api/bots/webapps#attachment-menu-mini-apps">attachment menu mini app »</a> as specified <ahref="/api/bots/webapps#attachment-menu-mini-apps">here »</a>.</li>
<li>Otherwise:<ul>
<li>If the user has just installed the attachment menu @ step 1, notify the user that the attachment menu was installed successfully.</li>
<li>Otherwise, notify the user that the attachment menu webapp can't be opened in the specified chat.</li>