mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-12-29 15:59:13 +01:00
230 lines
16 KiB
HTML
230 lines
16 KiB
HTML
<!DOCTYPE html>
|
||
<html class="">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>Introducing Bot API 2.0</title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta property="description" content="Howdy! This text assumes that you‘re familiar with Telegram’s bot platform.
|
||
If this is not the case, kindly check out our…">
|
||
<meta property="og:title" content="Introducing Bot API 2.0">
|
||
<meta property="og:image" content="4cffbe607dd6ff44bc">
|
||
<meta property="og:description" content="Howdy! This text assumes that you‘re familiar with Telegram’s bot platform.
|
||
If this is not the case, kindly check out our…">
|
||
<link rel="shortcut icon" href="/favicon.ico?4" type="image/x-icon" />
|
||
|
||
<link href="/css/bootstrap.min.css?3" rel="stylesheet">
|
||
|
||
<link href="/css/telegram.css?224" 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=""><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"></div>
|
||
<h1 id="dev_page_title">Introducing Bot API 2.0</h1>
|
||
|
||
<div id="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 <a href="/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 <a href="/bots/api#recent-changes"><strong>Bot API Manual</strong></a>.</p>
|
||
<h3><a class="anchor" name="new-inline-keyboards" href="#new-inline-keyboards"><i class="anchor-icon"></i></a>New Inline Keyboards</h3>
|
||
<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>
|
||
<a href="/file/811140217/1/NkRCCLeQZVc/17a804837802700ea4" target="_blank"><img src="/file/811140217/1/NkRCCLeQZVc/17a804837802700ea4" title="Callback buttons in @music" style="width: 295px; padding: 10px 20px;" /></a>
|
||
<a href="/file/811140659/1/RRJyulbtLBY/ea6163411c7eb4f4dc" target="_blank"><img src="/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: <a href="#callback-buttons">callback buttons</a>, <a href="#url-buttons">URL buttons</a> and <a href="#switch-to-inline-buttons">switch to inline buttons</a>.</p>
|
||
<blockquote>
|
||
<p><a href="/bots/api#inlinekeyboardmarkup">Manual: Inline keyboards »</a></p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="callback-buttons" href="#callback-buttons"><i class="anchor-icon"></i></a>Callback buttons</h4>
|
||
<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 <a href="/bots/api#answercallbackquery">result in a notification</a> at the top of the chat screen or in an alert.</p>
|
||
<div><center>
|
||
<a href="/file/811140423/1/6BVlO7dWPeo/64d0d842ff73ff3dc8" target="_blank"><img src="/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><a href="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 <a href="#updating-messages">updating messages</a> to find out how callback buttons can get even cooler.</p>
|
||
<h4><a class="anchor" name="url-buttons" href="#url-buttons"><i class="anchor-icon"></i></a>URL buttons</h4>
|
||
<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>
|
||
<div><center>
|
||
<a href="/file/811140999/1/2JSoUVlWKa0/4fad2e2743dc8eda04" target="_blank"><img src="/file/811140999/1/2JSoUVlWKa0/4fad2e2743dc8eda04" title="URL button" style="width:295px; padding:10px 20px"/></a></center>
|
||
</div>
|
||
|
||
<h4><a class="anchor" name="switch-to-inline-buttons" href="#switch-to-inline-buttons"><i class="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>
|
||
<a href="/file/811140659/1/RRJyulbtLBY/ea6163411c7eb4f4dc" target="_blank"><img src="/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><a href="https://telegram.me/sticker">@sticker</a> – This sticker search bot offers a <a href="#switch-to-inline-buttons">‘switch to inline’ button</a> to teach users how to use it in inline mode. </p>
|
||
<h3><a class="anchor" name="updating-messages" href="#updating-messages"><i class="anchor-icon"></i></a>Updating Messages</h3>
|
||
<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>
|
||
<div class="smartphone_video_player_wrap">
|
||
<div class="smartphone_video_player_iphone">
|
||
<video class="smartphone_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" poster="/resources/video/cover/Music.png" loop controls muted>
|
||
<source src="/resources/video/Music.mp4" type="video/mp4">
|
||
</video>
|
||
</div>
|
||
</div>
|
||
|
||
<p><strong>Sample bot</strong><br><a href="https://telegram.me/music">@music</a> – Watch how the music bot updates its messages with search results when you press the navigation buttons.</p>
|
||
<blockquote>
|
||
<p><a href="/bots/api#updating-messages">Manual: Updating messages »</a></p>
|
||
</blockquote>
|
||
<h3><a class="anchor" name="locations-and-numbers" href="#locations-and-numbers"><i class="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>
|
||
<a href="/file/811140587/2/jaowDLZg2l0/5ba3f7d7fd5c6c28dc" target="_blank"><img src="/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><a href="/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 <a href="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><a href="https://telegram.me/foursquare">@foursquare</a> – This bot will ask for permission to access the user's location, then provide geo-targeted results.</p>
|
||
<h3><a class="anchor" name="inline-bots-2-0" href="#inline-bots-2-0"><i class="anchor-icon"></i></a>Inline Bots 2.0</h3>
|
||
<p>Speaking of inline bots, they are also getting a major upgrade today.</p>
|
||
<h4><a class="anchor" name="new-types-of-content" href="#new-types-of-content"><i class="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>
|
||
<a href="/file/811140994/2/fvw-q_CRaBQ/c618325e119b0a8229" target="_blank"><img src="/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><a href="https://telegram.me/sticker">@sticker</a> – This sticker bot will accept one or more emoji and search for relevant stickers.<br><a href="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><a href="/bots/api#inlinequeryresult">Manual: Types of inline content »</a></p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="switching-between-inline-mode-and-private-chat" href="#switching-between-inline-mode-and-private-chat"><i class="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>
|
||
<a href="/file/811140951/1/FD93gAgDVDI/8d8bdd16e6a7b40c12" target="_blank"><img src="/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 <a href="/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><a href="https://telegram.me/youtube">@youtube</a> – Shows a ‘Sign in to YouTube’ button, then suggests personalized results.</p>
|
||
<blockquote>
|
||
<p><a href="/bots/api#answerinlinequery">Manual: Switch to PM</a></p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="better-inline-ui" href="#better-inline-ui"><i class="anchor-icon"></i></a>Better inline UI</h4>
|
||
<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>
|
||
<div><center>
|
||
<a href="/file/811140558/1/POjp00-nHqE/50d0312845a05e6da9" target="_blank"><img src="/file/811140558/1/POjp00-nHqE/50d0312845a05e6da9" title="New input field" style="width: 295px; padding: 10px 20px;" /></a></center><br>
|
||
</div>
|
||
|
||
<p>Tapping on the cross icon once will clear the query, tapping twice will give the ‘Send’ button back to the user.</p>
|
||
<h3><a class="anchor" name="group-admins" href="#group-admins"><i class="anchor-icon"></i></a>Group Admins</h3>
|
||
<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><a href="/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 <a href="https://telegram.me/botnews">@Botnews</a> channel on Telegram.</p>
|
||
<blockquote>
|
||
<p><a href="/bots/api#recent-changes">Read the full changelog for this update »</a></p>
|
||
</blockquote>
|
||
</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/blog">Blog</a></li>
|
||
<li><a href="//telegram.org/jobs">Jobs</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/dl/android">Android</a></li>
|
||
<li><a href="//telegram.org/dl/wp">Windows Phone</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="https://twitter.com/telegram" target="_blank" data-track="Follow/Twitter" onclick="trackDlClick(this, event)">Twitter</a></h5>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script src="/js/main.js?44"></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>
|
||
|