<h1id="dev_page_title">Introducing Bot API 2.0</h1>
<divid="dev_page_content"><!-- scroll_nav -->
<blockquote>
<p>Howdy! This text assumes that you‘re familiar with Telegram’s bot platform.<br>If this is not the case, kindly check out our <ahref="/bots"><strong>Introduction to Bots</strong></a>.</p>
</blockquote>
<p>Today we‘re introducing the biggest change to Telegram’s Bot Platform since June 2015. These new tools will help you create fluid and intuitive interfaces for your bots. And bots are becoming a lot more capable. They can now send any type of content supported on Telegram, provide location-based services and integrate with other services deeply based on users' phone numbers.</p>
<p>If you'd like a more concise changelog, you can find one in the <ahref="/bots/api#recent-changes"><strong>Bot API Manual</strong></a>.</p>
<p>To begin with, we're adding a new type of keyboard that is integrated directly into the message it belongs to. Inline keyboards are available for messages sent both in chat mode and inline mode.</p>
<div><center>
<ahref="/file/811140217/1/NkRCCLeQZVc/17a804837802700ea4"target="_blank"><imgsrc="/file/811140217/1/NkRCCLeQZVc/17a804837802700ea4"title="Callback buttons in @music"style="width: 295px; padding: 10px 20px;"/></a>
<ahref="/file/811140659/1/RRJyulbtLBY/ea6163411c7eb4f4dc"target="_blank"><imgsrc="/file/811140659/1/RRJyulbtLBY/ea6163411c7eb4f4dc"title="More callback buttons in @music"style="width: 295px; padding: 10px 20px;"/></a>
</center><br>
</div>
<p>Unlike with custom reply keyboards, pressing buttons on inline keyboards doesn't result in messages sent to the chat. Instead, inline keyboards support buttons that work behind the scenes: <ahref="#callback-buttons">callback buttons</a>, <ahref="#url-buttons">URL buttons</a> and <ahref="#switch-to-inline-buttons">switch to inline buttons</a>.</p>
<p>When a user presses a <strong>callback button</strong>, no messages are sent to the chat. Instead, your bot simply receives the relevant query. Upon receiving the query, your bot can display some <ahref="/bots/api#answercallbackquery">result in a notification</a> at the top of the chat screen or in an alert.</p>
<div><center>
<ahref="/file/811140423/1/6BVlO7dWPeo/64d0d842ff73ff3dc8"target="_blank"><imgsrc="/file/811140423/1/6BVlO7dWPeo/64d0d842ff73ff3dc8"title="Notification at the top"style="width:295px; padding:10px 20px"/></a></center><br>
</div>
<p><strong>Sample bot</strong><br><ahref="https://telegram.me/music">@music</a>– This sample music bot uses inline callback buttons to flip pages and reload random results.</p>
<p>Read on to <ahref="#updating-messages">updating messages</a> to find out how callback buttons can get even cooler.</p>
<p>Buttons of this type have a small arrow icon to help the user understand that tapping on a <strong>URL button</strong> will open an external link. Naturally, we'll show them a confirmation alert before opening the link in the browser.</p>
<h4><aclass="anchor"name="switch-to-inline-buttons"href="#switch-to-inline-buttons"><iclass="anchor-icon"></i></a>Switch to Inline buttons</h4>
<p>Pressing a switch to inline button prompts the user to select a chat, opens it and inserts the bot's username into the input field. You can also pass a query that will be inserted along with the username – this way your users will immediately get some inline results they can share.</p>
<div><center>
<ahref="/file/811140659/1/RRJyulbtLBY/ea6163411c7eb4f4dc"target="_blank"><imgsrc="/file/811140659/1/RRJyulbtLBY/ea6163411c7eb4f4dc"title="More callback buttons in @music"style="width: 295px; padding: 10px 20px;"/></a></center><br>
</div>
<p><strong>Sample bot</strong><br><ahref="https://telegram.me/sticker">@sticker</a>– This sticker search bot offers a <ahref="#switch-to-inline-buttons">‘switch to inline’ button</a> to teach users how to use it in inline mode. </p>
<p>Since inline keyboards don‘t send additional messages to the chat, it made sense to give bots a way of manipulating their existing messages, so that they don’t have to send a new message each time they need to update something. This helps reduce clutter and build more fluid interfaces.</p>
<p><strong>Sample bot</strong><br><ahref="https://telegram.me/music">@music</a>– Watch how the music bot updates its messages with search results when you press the navigation buttons.</p>
<h3><aclass="anchor"name="locations-and-numbers"href="#locations-and-numbers"><iclass="anchor-icon"></i></a>Locations and Numbers</h3>
<p>Some bots need extra data from the user to work properly. For example, knowing the user‘s location helps provide more relevant geo-specific results. The user’s phone number can be very useful for integrations with other services, like banks, etc.</p>
<p>We've added an easy way for bots to ask the user for their <strong>location</strong> and <strong>phone number</strong> using special buttons. Note that both phone number and location request buttons will only work in private chats.</p>
<div><center>
<ahref="/file/811140587/2/jaowDLZg2l0/5ba3f7d7fd5c6c28dc"target="_blank"><imgsrc="/file/811140587/2/jaowDLZg2l0/5ba3f7d7fd5c6c28dc"title="Phone number and location sharing buttons"style="width: 295px; padding: 10px 20px;"/></a></center><br>
</div>
<p>When these buttons are pressed, Telegram clients will display a confirmation alert that tells the user what's about to happen.</p>
<blockquote>
<p><ahref="/bots/api#keyboardbutton">Manual: Number and location buttons »</a></p>
</blockquote>
<p>Inline bots can also request location data from their users. Use the <code>/setinlinegeo</code> command with <ahref="https://telegram.me/botfather">@BotFather</a> to enable this. Your bot will ask the user for permission to access their location whenever they send an inline request.</p>
<p><strong>Sample bot</strong><br><ahref="https://telegram.me/foursquare">@foursquare</a>– This bot will ask for permission to access the user's location, then provide geo-targeted results.</p>
<p>Speaking of inline bots, they are also getting a major upgrade today.</p>
<h4><aclass="anchor"name="new-types-of-content"href="#new-types-of-content"><iclass="anchor-icon"></i></a>New types of content</h4>
<p>Inline bots now support <strong>all types of content</strong> available in Telegram (19 in all), they are now capable of sending stickers, videos, music, locations, documents and more. </p>
<div><center>
<ahref="/file/811140994/2/fvw-q_CRaBQ/c618325e119b0a8229"target="_blank"><imgsrc="/file/811140994/2/fvw-q_CRaBQ/c618325e119b0a8229"title="All kinds of inline content"style="width: 295px; padding: 10px 20px;"/></a></center><br>
</div>
<p><strong>Sample bots</strong><br><ahref="https://telegram.me/sticker">@sticker</a>– This sticker bot will accept one or more emoji and search for relevant stickers.<br><ahref="https://telegram.me/music">@music</a>– The music bot allows users to send mp3 tracks from a database of public domain classical music.</p>
<blockquote>
<p><ahref="/bots/api#inlinequeryresult">Manual: Types of inline content »</a></p>
</blockquote>
<h4><aclass="anchor"name="switching-between-inline-mode-and-private-chat"href="#switching-between-inline-mode-and-private-chat"><iclass="anchor-icon"></i></a>Switching between inline mode and private chat</h4>
<p>Some inline bots can benefit from an initial setup process, like connecting them to an account on an external service (e.g., YouTube). We've added an easy way of switching between the private chat with a bot and whatever chat the user wants to share inline results in.</p>
<div><center>
<ahref="/file/811140951/1/FD93gAgDVDI/8d8bdd16e6a7b40c12"target="_blank"><imgsrc="/file/811140951/1/FD93gAgDVDI/8d8bdd16e6a7b40c12"title="Switch to PM button"style="width: 295px; padding: 10px 20px;"/></a></center><br>
</div>
<p>You can now display a special ‘Switch to PM’ button above the inline results (or instead of them). This button will open a private chat with the bot and pass a parameter of your choosing, so that you can prompt the user for the relevant setup actions. Once done, you can use an inline keyboard with a <ahref="/bots/api#inlinekeyboardmarkup"><em>switch_inline_query</em></a> button to send the user back to the original chat. </p>
<p><strong>Sample bots</strong><br><ahref="https://telegram.me/youtube">@youtube</a>– Shows a ‘Sign in to YouTube’ button, then suggests personalized results.</p>
<blockquote>
<p><ahref="/bots/api#answerinlinequery">Manual: Switch to PM</a></p>
<p>Since sending content via inline bots works differently from sending ordinary messages, we‘ve changed the interface a little. There’s hardly a more effective way of explaining that there‘s no need to hit ’Send':</p>
<p>As a dessert, we‘re beginning to roll out tools that will allow you to create bot solutions for group admins. As the first step, we’ve added methods to remove members from groups and supergroups.</p>
<blockquote>
<p><ahref="/bots/api#kickchatmember">Manual: Group management »</a></p>
</blockquote>
<p>And that's about it for now. Stay tuned for more updates and subscribe to our official <ahref="https://telegram.me/botnews">@Botnews</a> channel on Telegram.</p>
<blockquote>
<p><ahref="/bots/api#recent-changes">Read the full changelog for this update »</a></p>
</blockquote>
</div>
</div>
</div>
</div>
<divclass="footer_wrap">
<divclass="footer_columns_wrap footer_desktop">
<divclass="footer_column footer_column_telegram">
<h5>Telegram</h5>
<divclass="footer_telegram_description"></div>
Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.