CINXE.COM
Bots
<!DOCTYPE html> <html class=""> <head> <meta charset="utf-8"> <title>Bots</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta property="description" content="Working with bots, using the MTProto API."> <meta property="og:title" content="Bots"> <meta property="og:image" content=""> <meta property="og:description" content="Working with bots, using the MTProto API."> <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?244" 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" >Bots</a></li></ul></div> <h1 id="dev_page_title">Bots</h1> <div id="dev_page_content"><!-- scroll_nav --> <p>Working with bots, using the MTProto API.</p> <p>See <a href="/bots">here</a> for more info about bots. </p> <p>Please note that you can also use the simplified <a href="/bots/api">HTTP Bot API</a> to use bots, see <a href="/bots">here for more info »</a>.</p> <h3><a class="anchor" href="#login" id="login" name="login"><i class="anchor-icon"></i></a>Login</h3> <pre><code>---functions--- <a href='/method/auth.importBotAuthorization'>auth.importBotAuthorization</a>#67a3ff2c flags:<a href='/type/int'>int</a> api_id:<a href='/type/int'>int</a> api_hash:<a href='/type/string'>string</a> bot_auth_token:<a href='/type/string'>string</a> = <a href='/type/auth.Authorization'>auth.Authorization</a>;</code></pre> <p>In order to login as a bot, instead of using the <a href="/api/auth">standard login code flow</a>, simply provide the <a href="/bots#how-do-i-create-a-bot">bot token</a> generated by <a href="https://t.me/botfather">@botfather</a>.<br> You must still provide your <a href="/api/obtaining_api_id#obtaining-api-id">API ID</a>, as per user logins. </p> <p>After successful authorization, you will be able to use <a href="/methods">most MTProto API methods</a>, just as any normal user.<br> Methods that can be called by bots will have a <strong>Bots can use this method</strong> notice. </p> <h3><a class="anchor" href="#edit-bot-information-" id="edit-bot-information-" name="edit-bot-information-"><i class="anchor-icon"></i></a><a href="/api/bots/info">Edit bot information »</a></h3> <p>Users can edit and localize the profile picture, name, about text and description of bots they own; the same can be done by the bots themselves. </p> <h3><a class="anchor" href="#commands-" id="commands-" name="commands-"><i class="anchor-icon"></i></a><a href="/api/bots/commands">Commands »</a></h3> <p><a href="/bots">Bots</a> offer a set of commands that can be used by users in private, or in a chat. </p> <h3><a class="anchor" href="#buttons-" id="buttons-" name="buttons-"><i class="anchor-icon"></i></a><a href="/api/bots/buttons">Buttons »</a></h3> <p>Users can interact with your bot via <strong>buttons</strong> or even <strong>inline buttons</strong>, straight from inline <strong>messages</strong> in <strong>any</strong> chat. </p> <h3><a class="anchor" href="#menu-button-" id="menu-button-" name="menu-button-"><i class="anchor-icon"></i></a><a href="/api/bots/menu">Menu button »</a></h3> <p>Bots can choose the behavior of the menu button shown next to the text input field. </p> <h3><a class="anchor" href="#suggested-bot-admin-rights-" id="suggested-bot-admin-rights-" name="suggested-bot-admin-rights-"><i class="anchor-icon"></i></a><a href="/api/rights#suggested-bot-rights">Suggested bot admin rights »</a></h3> <p>Bots can suggest a set of admin rights when being added to groups and channels.</p> <h3><a class="anchor" href="#inline-queries-" id="inline-queries-" name="inline-queries-"><i class="anchor-icon"></i></a><a href="/api/bots/inline">Inline queries »</a></h3> <p>Users can interact with your bot via <strong>inline queries</strong>, straight from the <strong>text input field</strong> in <strong>any</strong> chat. </p> <h3><a class="anchor" href="#games-" id="games-" name="games-"><i class="anchor-icon"></i></a><a href="/api/bots/games">Games »</a></h3> <p>Bots can offer users HTML5 games to play solo or to compete against each other in groups and one-on-one chats; how to work with games in the MTProto API.</p> <h3><a class="anchor" href="#web-apps-" id="web-apps-" name="web-apps-"><i class="anchor-icon"></i></a><a href="/api/bots/webapps">Web apps »</a></h3> <p>Bots can offer users interactive <a href="/bots/webapps">HTML5 web apps</a> to completely replace <strong>any website</strong>. </p> <h4><a class="anchor" href="#affiliate-programs" id="affiliate-programs" name="affiliate-programs"><i class="anchor-icon"></i></a><a href="/api/bots/referrals">Affiliate programs</a></h4> <p>Developers can open affiliate programs for their <a href="/api/bots/webapps">mini app</a> – allowing <strong>content creators</strong>, other <strong>mini app developers</strong> and <strong>any Telegram user</strong> to promote it and earn commissions on purchases made by people they referred.</p> <h3><a class="anchor" href="#attachment-menu-" id="attachment-menu-" name="attachment-menu-"><i class="anchor-icon"></i></a><a href="/api/bots/attach">Attachment menu »</a></h3> <p>Bots can install attachment menu entries, offering conveniently accessible, versatile web apps.</p> <h3><a class="anchor" href="#business-bots-" id="business-bots-" name="business-bots-"><i class="anchor-icon"></i></a><a href="/api/business#connected-bots">Business bots »</a></h3> <p>Business users can connect Telegram bots that will process and answer messages <strong>on their behalf</strong>. This allows businesses to <strong>seamlessly integrate</strong> any existing tools and workflows, or add <strong>AI assistants</strong> that manage their chats. </p> <h3><a class="anchor" href="#bot-api-dialog-ids" id="bot-api-dialog-ids" name="bot-api-dialog-ids"><i class="anchor-icon"></i></a><a href="/api/bots/ids">Bot API dialog IDs</a></h3> <p>How to convert MTProto peer IDs to bot API dialog IDs and vice versa.</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/press">Press</a></h5> </div> <div class="footer_column"> <h5><a href="//telegram.org/moderation">Moderation</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> <!-- page generated in 16.43ms -->