mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-11-28 19:23:11 +01:00
641 lines
56 KiB
HTML
641 lines
56 KiB
HTML
<!DOCTYPE html>
|
||
<html class="">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>Telegram Bot Features</title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta property="description" content="This page describes individual bot elements in greater detail. For a general overview of bots, read the introduction to bots first.">
|
||
<meta property="og:title" content="Telegram Bot Features">
|
||
<meta property="og:image" content="https://core.telegram.org/file/464001858/11318/ahAJjwERIX8.164875/ce1372cbf73e3ea94e">
|
||
<meta property="og:description" content="This page describes individual bot elements in greater detail. For a general overview of bots, read the introduction to bots first.">
|
||
<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?236" 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"><ul class="breadcrumb clearfix"><li><a href="/bots" >Telegram Bots</a></li><i class="icon icon-breadcrumb-divider"></i><li><a href="/bots/features" >Telegram Bot Features</a></li></ul></div>
|
||
<h1 id="dev_page_title">Telegram Bot Features</h1>
|
||
|
||
<div id="dev_page_content"><!-- scroll_nav -->
|
||
|
||
<p>This page describes individual <strong>bot elements</strong> and <strong>features</strong> in detail. See also:</p>
|
||
<ul>
|
||
<li><a href="/bots">A General Bot Platform Overview</a></li>
|
||
<li><a href="/bots/api">Full API Reference for Developers</a></li>
|
||
</ul>
|
||
<h3><a class="anchor" name="what-features-do-bots-have" href="#what-features-do-bots-have"><i class="anchor-icon"></i></a>What features do bots have?</h3>
|
||
<ul>
|
||
<li><a href="#inputs"><strong>Inputs</strong></a><ul>
|
||
<li><a href="#inputs">Text</a></li>
|
||
<li><a href="#commands">Commands</a></li>
|
||
<li><a href="#keyboards">Buttons</a> </li>
|
||
<li><a href="#chat-and-user-selection">Chat and User Selection</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#interactions"><strong>Interactions</strong></a><ul>
|
||
<li><a href="#inline-requests">Inline</a></li>
|
||
<li><a href="#deep-linking">Deep Linking</a></li>
|
||
<li><a href="#attachment-menu">Attachment Menu</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#integration"><strong>Integration</strong></a><ul>
|
||
<li><a href="#web-apps">Web Apps</a></li>
|
||
<li><a href="#payments">Payments</a></li>
|
||
<li><a href="#web-login">Web Login</a></li>
|
||
<li><a href="#html5-games">HTML5 Games</a></li>
|
||
<li><a href="#stickers">Stickers</a> </li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#language-support"><strong>Language Support</strong></a></li>
|
||
<li><a href="#bot-management"><strong>Bot Management</strong></a><ul>
|
||
<li><a href="#privacy-mode">Privacy Mode</a></li>
|
||
<li><a href="#testing-your-bot">Testing Your Bot</a></li>
|
||
<li><a href="#status-alerts">Status Alerts</a></li>
|
||
<li><a href="#local-bot-api">Local API</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#botfather"><strong>BotFather, creating and managing bots</strong></a></li>
|
||
</ul>
|
||
<hr>
|
||
<h3><a class="anchor" name="inputs" href="#inputs"><i class="anchor-icon"></i></a>Inputs</h3>
|
||
<p>Users can send <strong>messages of all types</strong> to bots, including text, files, locations, stickers, voice messages and even <a href="/bots/api#dice">dice</a> if they're feeling lucky. However, Telegram bots offer many other tools for building flexible interfaces tailored to your specific needs:</p>
|
||
<ul>
|
||
<li><a href="#commands">Commands</a> that are highlighted in messages and can be selected from a list after typing <code>/</code>.</li>
|
||
<li><a href="#keyboards">Keyboards</a> that replace the user's keyboard with predefined answer options.</li>
|
||
<li><a href="#inline-keyboards">Buttons</a> that are shown next to messages from the bot.</li>
|
||
</ul>
|
||
<p>For even more flexibility, <a href="#web-apps">Web Apps</a> support 100% custom interfaces with JavaScript. </p>
|
||
<div>
|
||
<a href="/file/464001858/11318/ahAJjwERIX8.164875/ce1372cbf73e3ea94e" target="_blank"><img src="/file/464001858/11318/ahAJjwERIX8.164875/ce1372cbf73e3ea94e" title="Inputs" class="dev_page_image" width=70% /></a>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong> Telegram bots can support <a href="#language-support">multiple languages</a> that adapt to the users' language settings in the app.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="commands" href="#commands"><i class="anchor-icon"></i></a>Commands</h4>
|
||
<p>A command is a simple <code>/keyword</code> that tells the bot what to do. Telegram apps will:</p>
|
||
<ul>
|
||
<li><strong>Highlight</strong> commands in messages. When the user taps a highlighted command, that command is immediately sent again.</li>
|
||
<li>Suggest a <strong>list of supported commands</strong> with descriptions when the user enters a <code>/</code> (for this to work, you need to have provided a list of commands to <a href="https://t.me/botfather">@BotFather</a> or via the <a href="/bots/api#setmycommands">appropriate API method</a>). Selecting a command from the list immediately sends it.</li>
|
||
<li>Show a <a href="#menu-button">menu button</a> containing all or some of a bot’s commands (which you set via <a href="https://t.me/botfather">@BotFather</a>).</li>
|
||
</ul>
|
||
<p>Commands must always start with the <code>/</code> symbol and contain <strong>up to 32 characters</strong>. They can use <strong>Latin letters</strong>, <strong>numbers</strong> and <strong>underscores</strong>, though simple lowercase text is recommended for a cleaner look. </p>
|
||
<p>Here are a few examples:</p>
|
||
<ul>
|
||
<li>/next </li>
|
||
<li>/cancel </li>
|
||
<li>/newlocation </li>
|
||
<li>/newrule </li>
|
||
</ul>
|
||
<p>Commands should be <strong>as specific as possible</strong> – for example <code>/newlocation</code> or <code>/newrule</code> <strong>is better</strong> than a <code>/new</code> command that then requires an additional parameter from the user like "<em>location</em>“ or ”<em>rule</em>".</p>
|
||
<div>
|
||
<a href="/file/464001775/10227/HCr0XgSUHrg.119089/c17ff5d34fe528361e" target="_blank"><img src="/file/464001775/10227/HCr0XgSUHrg.119089/c17ff5d34fe528361e" title="Commands" class="dev_page_image"
|
||
width=44% /></a>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>We require <strong>all developers</strong> to support several <a href="#global-commands">Global Commands</a> to make sure Telegram bots offer a consistent and user-friendly experience.</p>
|
||
</blockquote>
|
||
<h5><a class="anchor" name="command-scopes" href="#command-scopes"><i class="anchor-icon"></i></a>Command Scopes</h5>
|
||
<p>Your bot is able to <strong>show different commands</strong> to different users and groups – you can control this using <a href="/bots/api#botcommandscope">scopes</a>. For example, your bot could show additional commands to group admins or translate the list based on the user’s <a href="/bots/api#user">language_code</a>.</p>
|
||
<blockquote>
|
||
<p>Keep in mind that Bot API <a href="/bots/api#update">updates</a> <strong>will not contain any information</strong> about the scope of a command sent by the user – in fact, they may contain commands that don’t exist at all in your bot. Your backend should <strong>always</strong> verify that received commands are valid and that the user was authorized to use them regardless of scope.</p>
|
||
<p>Bots with privacy mode enabled will only receive commands in groups under special conditions, <a href="#privacy-mode">see here</a>.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="keyboards" href="#keyboards"><i class="anchor-icon"></i></a>Keyboards</h4>
|
||
<p>Bots are able to interpret free text input from users, but offering <strong>specific suggestions</strong> is often more intuitive – this is where <strong>custom keyboards</strong> can be extremely useful.</p>
|
||
<p>Whenever your bot sends a message, it can <strong>display a special keyboard</strong> with predefined reply options (see <a href="/bots/api#replykeyboardmarkup">ReplyKeyboardMarkup</a>). Telegram apps that receive the message will display your keyboard to the user. Using any of the buttons will immediately send the respective text. This way you can drastically <strong>simplify</strong> and <strong>streamline</strong> user interaction with your bot.</p>
|
||
<div>
|
||
<a href="/file/464001950/1191a/2RwpmgU-swU.123554/b50478c124d5914c23" target="_blank"><img src="/file/464001950/1191a/2RwpmgU-swU.123554/b50478c124d5914c23" title="Keyboards" class="dev_page_image" width=44% /></a>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>Check out the <a href="/bots/api#replykeyboardmarkup">one_time_keyboard</a> parameter to automatically hide your bot's keyboard as soon as it's been used.</p>
|
||
</blockquote>
|
||
<p>You can also <strong>customize the text placeholder</strong> in the input field by setting the <code>input_field_placeholder</code> parameter.</p>
|
||
<h4><a class="anchor" name="inline-keyboards" href="#inline-keyboards"><i class="anchor-icon"></i></a>Inline Keyboards</h4>
|
||
<p>There are times when you'd prefer to do things <strong>without sending any messages</strong> to the chat – like when a user is changing settings, toggling options or navigating search results. In such cases, you can use <a href="/bots/api#inlinekeyboardmarkup">Inline Keyboards</a> that are shown directly below their relevant messages.</p>
|
||
<p>Unlike with custom reply keyboards, pressing buttons on inline keyboards <strong>doesn't send messages to the chat</strong>. Instead, inline keyboards support buttons that can work behind the scenes or open different interfaces: <a href="/bots/api#inlinekeyboardbutton">callback buttons</a>, <a href="/bots/api#inlinekeyboardbutton">URL buttons</a>, <a href="/bots/api#inlinekeyboardbutton">switch-to-inline buttons</a>, <a href="/bots/api#inlinekeyboardbutton">game buttons</a> and <a href="/bots/api#inlinekeyboardbutton">payment buttons</a>. </p>
|
||
<div>
|
||
<a href="/file/464001863/110f3/I47qTXAD9Z4.120010/e0ea04f66357b640ec" target="_blank"><img src="/file/464001863/110f3/I47qTXAD9Z4.120010/e0ea04f66357b640ec" title="Inline Keyboard" class="dev_page_image" width=44% /></a>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>To provide a <strong>better user experience</strong>, consider <a href="/bots/api#editmessagereplymarkup">editing your keyboard</a> when the user toggles a setting button or navigates to a new page – this is both <strong>faster</strong> and <strong>smoother</strong> than sending a whole new message and deleting the previous one.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="menu-button" href="#menu-button"><i class="anchor-icon"></i></a>Menu Button</h4>
|
||
<p>In all bot chats, a menu button appears near the message field. By default, tapping this button <strong>opens a menu</strong> that can hold some or all of a bot's commands, including a short description for each. Users can then <strong>select a command from the menu</strong> without needing to type it out.</p>
|
||
<p>You can set different texts of the menu button and its command descriptions for various <strong>individual users</strong> or <strong>groups of users</strong> – for example, showing translated text based on the user’s language, as explained <a href="#commands">here</a>.</p>
|
||
<div class="blog_video_player_wrap" style="max-width: 400px; margin: 20px auto 20px;">
|
||
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay="" loop="" controls="" muted="" poster="/file/464001581/11d85/f42u9c5Wncg.133752/b5a95b7f1221032d7d" style="max-width: 400px;" title="Bot Menu Button" alt="Video: Bot Menu Button">
|
||
<source src="/file/464001555/10fbd/jvTuV2Ke7WQ.1916669.mp4/a056de323645db409d" type="video/mp4">
|
||
</video>
|
||
</div>
|
||
|
||
<p>The <strong>menu button</strong> can alternatively be used to launch a <a href="#web-apps">Web App</a>.</p>
|
||
<h4><a class="anchor" name="global-commands" href="#global-commands"><i class="anchor-icon"></i></a>Global Commands</h4>
|
||
<p>To make basic interactions more uniform, we ask all developers to support a few <strong>basic commands</strong>. Telegram apps will have interface shortcuts for these commands.</p>
|
||
<ul>
|
||
<li>/start - begins the interaction with the user, like sending an introductory message. This command can also be used to pass additional parameters to the bot (see <a href="#deep-linking">Deep Linking</a>).</li>
|
||
<li>/help - returns a help message, like a short text about what your bot can do and a list of commands.</li>
|
||
<li>/settings - (if applicable) shows the bot's settings for this user and suggests commands to edit them.</li>
|
||
</ul>
|
||
<p>Users will see a <strong>Start</strong> button the first time they open a chat with your bot. <strong>Help</strong> and <strong>Settings</strong> links will be available in the menu on the bot's profile page if you add them in <a href="https://t.me/botfather">@BotFather</a>.</p>
|
||
<h3><a class="anchor" name="chat-and-user-selection" href="#chat-and-user-selection"><i class="anchor-icon"></i></a>Chat and User Selection</h3>
|
||
<p>Bots can present the user with a <strong>friendly</strong> and <strong>intuitive</strong> interface that lists any number of groups, channels or other users according to a custom set of <strong>criteria</strong>. Tapping on a chat will send its identifier to the bot in a service message and seamlessly close the interface.</p>
|
||
<p>A group management bot is the <strong>perfect example</strong>: an admin could select a chat the bot should manage, and then select a user it should promote – this would happen without ever typing any text.</p>
|
||
<p>Here is a <strong>quick start guide</strong> to use this feature:</p>
|
||
<ul>
|
||
<li>Pick a set of criteria and store them in a <a href="https://core.telegram.org/bots/api#keyboardbuttonrequestchat">KeyboardButtonRequestChat</a> object (or <a href="https://core.telegram.org/bots/api#keyboardbuttonrequestuser">KeyboardButtonRequestUser</a> for users).</li>
|
||
<li>Create a <a href="https://core.telegram.org/bots/api#keyboardbutton">KeyboardButton</a> and store the criteria under <code>request_chat</code> or <code>request_user</code> respectively.</li>
|
||
<li>Send a <a href="https://core.telegram.org/bots/api#replykeyboardmarkup">ReplyKeyboardMarkup</a> that contains the button you just created.</li>
|
||
<li>When the user selects a chat, you'll receive its identifier in a <code>chat_shared</code> or <code>user_shared</code> service message.</li>
|
||
</ul>
|
||
<div class="blog_video_player_wrap" style="max-width: 400px; margin: 20px auto 20px;">
|
||
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" loop="" muted="" poster="/file/464001277/1132d/dAINJNWL9jw.34909/08eaf646c24be49a87" style="max-width: 400px;" title="Select Chats For Bots" alt="Select Chats For Bots" vindex="1" preload="auto">
|
||
<source src="/file/464001095/11121/M6HpBwtivTE.1913043.mp4/0514a29affa78a6dca" type="video/mp4">
|
||
</video>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>Keep in mind that the bot may not be able to use the identifier it receives if the corresponding chat or user is not already known or accessible by some other means.</p>
|
||
</blockquote>
|
||
<hr>
|
||
<h3><a class="anchor" name="interactions" href="#interactions"><i class="anchor-icon"></i></a>Interactions</h3>
|
||
<p>In addition to sending commands and messages to the chat with the bot, there are several ways of interacting with them without opening any specific chat or group.</p>
|
||
<ul>
|
||
<li><a href="#inline-requests"><strong>Inline mode</strong></a> allows sending requests to bots right from the input field – from any chat on Telegram.</li>
|
||
<li><a href="#deep-linking"><strong>Deep linking</strong></a> allows special links that send certain parameters to the bot when opened.</li>
|
||
<li><a href="#attachment-menu"><strong>Attachment menu</strong></a> integration makes it possible to use bots from the attachment menu in chats.</li>
|
||
</ul>
|
||
<h4><a class="anchor" name="inline-requests" href="#inline-requests"><i class="anchor-icon"></i></a>Inline Requests</h4>
|
||
<p>Users can interact with your bot via <strong>inline queries</strong> straight from the message field <strong>in any chat</strong>. All they need to do is start a message with your bot's <em>@username</em> and enter a keyword.</p>
|
||
<p>Having received the query, your bot can return some results. As soon as the user selects one, it is sent to the <strong>relevant chat</strong>. This way, people can request and send content from your bot in any of their chats, groups or channels.</p>
|
||
<p>Remember that inline functionality has to be enabled via <a href="https://t.me/botfather">@BotFather</a>, or your bot will not receive inline <a href="/bots/api#update">Updates</a>.</p>
|
||
<div>
|
||
<a href="/file/464001466/10e4a/r4FKyQ7gw5g.134366/f2606a53d683374703" target="_blank"><img src="/file/464001466/10e4a/r4FKyQ7gw5g.134366/f2606a53d683374703" title="Inline Mode" class="dev_page_image" width=51%/></a>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>Examples of inline bots include <a href="https://gif.t.me">@gif</a>, <a href="https://bing.t.me">@bing</a> and <a href="https://wiki.t.me">@wiki</a>. <a href="#web-apps">Web App</a> bots can also be used inline – try typing <a href="https://durgerkingbot.t.me">@durgerkingbot</a> in any chat.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="deep-linking" href="#deep-linking"><i class="anchor-icon"></i></a>Deep Linking</h4>
|
||
<p>Telegram bots have a deep linking mechanism that allows <strong>additional parameters</strong> to be passed to the bot on startup. It could be a command that launches the bot – or an authentication token to connect the user's Telegram account to their account on another platform.</p>
|
||
<p>Each bot has a link that <strong>opens a conversation</strong> with it in Telegram – <code>https://t.me/<bot_username></code>. Parameters can be added directly to this link to let your bot work with additional information on the fly, without any user input.</p>
|
||
<blockquote>
|
||
<p>A-Z, a-z, 0-9, _ and - are allowed. We recommend using base64url to encode parameters with binary and other types of content. The parameter can be up to 64 characters long.</p>
|
||
</blockquote>
|
||
<p><strong>Private Chats</strong><br>In private chats, you can use the <code>start</code> parameter to automatically pass any value to your bot whenever a user presses the link. For example, you could use:</p>
|
||
<pre><code>https://t.me/your_bot?start=airplane</code></pre>
|
||
<p>When someone opens a chat with your bot via this link, you will receive:</p>
|
||
<pre><code>/start airplane</code></pre>
|
||
<p><strong>Groups</strong><br>In groups, you can add the parameter <code>startgroup</code> to this link. For example:</p>
|
||
<pre><code>https://t.me/your_bot?startgroup=spaceship</code></pre>
|
||
<p>Following a link with this parameter prompts the user to select a group to add the bot to – the resulting update will contain text in the form:</p>
|
||
<pre><code>/start@your_bot spaceship</code></pre>
|
||
<blockquote>
|
||
<p><a href="#web-apps">Web Apps</a> also support deep linking, for more information check out our <a href="/bots/webapps#adding-bots-to-the-attachment-menu">dedicated guide</a>.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="attachment-menu" href="#attachment-menu"><i class="anchor-icon"></i></a>Attachment Menu</h4>
|
||
<p>Certain bots can be added directly to a user’s <strong>attachment menu</strong> – giving them easy access to the bot in any chat. Currently, this option is restricted to certain <a href="/bots/webapps#launching-web-apps-from-the-attachment-menu">approved bots</a>, but may be expanded later.</p>
|
||
<div class="blog_video_player_wrap" style="max-width: 400px; margin: 20px auto 20px;">
|
||
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay="" loop="" controls="" muted="" poster="/file/464001491/11651/uwMWNdO29NE.215169/1b37285bbd8fc81244" style="max-width: 400px;" title="Attachment Menu" alt="Video: Bot Attachment Menu">
|
||
<source src="/file/464001177/11b03/ruSbBLQiLJ8.928268.mp4/d9ad95048d23f3cc3f" type="video/mp4">
|
||
</video>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>Try adding <a href="https://t.me/durgerkingbot?startattach">@DurgerKingBot</a> to your attachment menu.</p>
|
||
</blockquote>
|
||
<hr>
|
||
<h3><a class="anchor" name="integration" href="#integration"><i class="anchor-icon"></i></a>Integration</h3>
|
||
<p>There are various ways of futher integrating bots with Telegram and other services.</p>
|
||
<ul>
|
||
<li>Use <a href="#web-apps">Web Apps</a> to replace any website.</li>
|
||
<li>Accept <a href="#payments">Payments</a> via dozens of integrated third-party payment providers.</li>
|
||
<li>Connect to Telegram using the <a href="#web-login">Web Login</a> functionality.</li>
|
||
<li>Create gaming bots by integrating <a href="#html5-games">HTML5 Games</a>.</li>
|
||
<li>Help users create and manage <a href="#stickers">Telegram Stickers</a>.</li>
|
||
</ul>
|
||
<h3><a class="anchor" name="web-apps" href="#web-apps"><i class="anchor-icon"></i></a>Web Apps</h3>
|
||
<p>Bots can easily process <strong>complex inputs</strong> of any kind and <strong>dynamic interaction flows</strong> via <a href="webapps">Web Apps</a>. With this unique feature, you can develop any number of flexible, streamlined interfaces in <strong>JavaScript</strong>.</p>
|
||
<blockquote>
|
||
<p>Web Apps are covered in detail in our <a href="webapps">dedicated guide</a> – you should read it carefully to learn the wide variety of features they can offer.</p>
|
||
</blockquote>
|
||
<div class="blog_video_player_wrap" style="max-width: 400px; margin: 20px auto 20px;">
|
||
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay="" loop="" controls="" muted="" poster="/file/464001434/100bf/eWprjdgzEbE.100386/644bbea83084f44c8f" style="max-width: 400px;" title="Attachment Menu" alt="Video: Bot Attachment Menu">
|
||
<source src="/file/464001679/11aa9/KQx_BlPVXRo.4922145.mp4/c65433c8ac11a347a8" type="video/mp4">
|
||
</video>
|
||
</div>
|
||
|
||
<p>If you develop a <strong>Web App</strong>, be sure to follow our <a href="webapps#design-guidelines">design guidelines</a> – you'll want your custom interface to <strong>seamlessly integrate</strong> into the app to provide users the best possible experience.</p>
|
||
<h3><a class="anchor" name="payments" href="#payments"><i class="anchor-icon"></i></a>Payments</h3>
|
||
<p>Telegram bots can accept payments with a sleek, streamlined interface that collects all necessary data from the user. Telegram <strong>doesn't collect</strong> any payment data – like the user's credit card information – and sends it directly to one of the supported <a href="payments#supported-payment-providers">payment providers</a>.</p>
|
||
<p>Here is a <strong>quick start guide</strong> to implement payments:</p>
|
||
<ul>
|
||
<li>Pick a <a href="payments#supported-payment-providers">provider</a> and obtain the <a href="payments#getting-a-token">proper token</a> as well as a <strong>test token</strong> from the "<strong>Stripe TEST MODE</strong>" provider.</li>
|
||
<li>Implement payments via the <a href="/bots/api#payments">appropriate API methods</a>.</li>
|
||
<li>Test your implementation by using your <strong>test token</strong> along with a <a href="https://stripe.com/docs/testing#cards">test credit card</a>.</li>
|
||
</ul>
|
||
<p>Then, to issue an <strong>invoice</strong> and process the order flow:</p>
|
||
<ul>
|
||
<li><a href="/bots/api#sendinvoice">Send an invoice</a> to the user for the goods or services you are offering.</li>
|
||
<li>Validate the order and accept the checkout via <a href="/bots/api#answerprecheckoutquery">answerPreCheckoutQuery</a>.</li>
|
||
<li>Confirm the payment by checking for a <a href="/bots/api#successfulpayment">successful payment service message</a>.</li>
|
||
<li>Ship the goods or provide the services.</li>
|
||
</ul>
|
||
<p>A full and exhaustive guide, including live checklist, parameters and in-depth method descriptions is available <a href="/bots/payments">here</a>. We <strong>strongly recommend</strong> that you read the full guide before going live.</p>
|
||
<div>
|
||
<a href="/file/464001393/101fc/SB_bFCLR0tg.130549/7ecf91aaa44737e8cb" target="_blank"><img src="/file/464001393/101fc/SB_bFCLR0tg.130549/7ecf91aaa44737e8cb" title="Payments" class="dev_page_image" width=50% /></a>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>Telegram does not directly process the payments, does not store data about orders and does not collect any fees. Invoices are forwarded directly to the payment provider.<br>For this reason, disputes must be solved between the user, the bot developer and the payment provider. You can read more about this in the <a href="https://telegram.org/privacy#7-third-party-payment-services">Privacy Policy</a>.</p>
|
||
</blockquote>
|
||
<h3><a class="anchor" name="web-login" href="#web-login"><i class="anchor-icon"></i></a>Web Login</h3>
|
||
<p>Telegram offers a <strong>flexible</strong>, <strong>lightweight</strong> and <strong>free</strong> framework to authenticate users on any website and app. This can be used to bridge your platform with Telegram, providing a smooth experience to your users. You can also freely rely on this framework to implement a <strong>fast</strong> and <strong>signup-free</strong> login on your site, regardless of its connection to Telegram.</p>
|
||
<h4><a class="anchor" name="widgets" href="#widgets"><i class="anchor-icon"></i></a>Widgets</h4>
|
||
<p>The Telegram login widget is a <strong>simple and secure way to authorize users</strong> on your website.</p>
|
||
<ol>
|
||
<li>Choose a bot – ideally its name and profile pic <strong>should match</strong> the website title and logo.</li>
|
||
<li>Use the <code>/setdomain</code> command in <a href="https://t.me/botfather">@BotFather</a> to pair the bot with your website domain. </li>
|
||
<li>Configure your widget using <a href="/widgets/login#widget-configuration">our dedicated tool</a> and embed it on your website.</li>
|
||
</ol>
|
||
<h4><a class="anchor" name="inline-login" href="#inline-login"><i class="anchor-icon"></i></a>Inline Login</h4>
|
||
<p>When users open your website via an <strong>inline button</strong>, you can use the <a href="/bots/api#loginurl">login_url</a> parameter as an alternative to login widgets. This way, you'll be able to <a href="https://telegram.org/blog/privacy-discussions-web-bots#meet-seamless-web-bots">seamlessly authorize</a> them on your website or app before the page even loads.</p>
|
||
<div>
|
||
<a href="/file/464001287/105ea/23bO4ntH4tc.43741/c9624e36c3462b6540" target="_blank"><img src="/file/464001287/105ea/23bO4ntH4tc.43741/c9624e36c3462b6540" width=50% title="Login Widget" class="dev_page_image" /></a>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>Make sure to review our <a href="/widgets/login#checking-authorization">guide</a> on authenticating the received data as well as our <a href="https://gist.github.com/anonymous/6516521b1fb3b464534fbc30ea3573c2">sample code</a>.</p>
|
||
</blockquote>
|
||
<h3><a class="anchor" name="html5-games" href="#html5-games"><i class="anchor-icon"></i></a>HTML5 Games</h3>
|
||
<p>Bots can serve as <strong>standalone gaming platforms</strong> – with our <a href="/bots/api#games">HTML5 Gaming API</a> you can develop multiplayer or single-player games and let your users have fun comparing <strong>ranks</strong>, <strong>scores</strong> and much more.</p>
|
||
<p>To get started, follow these simple steps:</p>
|
||
<ul>
|
||
<li>Send the <code>/newgame</code> command to <a href="https://t.me/botfather">@BotFather</a></li>
|
||
<li>Provide a <strong>description text</strong>, an <strong>image</strong> or an <strong>optional gif</strong> to showcase its gameplay</li>
|
||
<li>Send the game to users via the <a href="/bots/api#sendgame">sendGame</a> method or via an <a href="/bots/api#inlinequeryresultgame">inline query</a></li>
|
||
<li>When someone wants to play, you'll receive the appropriate <code>game_short_name</code> in a <a href="/bots/api#callbackquery">CallbackQuery</a></li>
|
||
<li>To launch the game, provide the <strong>HTML5 Game URL</strong> as the <code>url</code> param of <a href="/bots/api#answercallbackquery">answerCallbackQuery</a></li>
|
||
</ul>
|
||
<p>Then, to handle <strong>highscores</strong>:</p>
|
||
<ul>
|
||
<li>Use <a href="/bots/api#setgamescore">setGameScore</a> to post high scores in the chat with the game</li>
|
||
<li>Use <a href="/bots/api#getgamehighscores">getGameHighScores</a> to get in-game high score tables</li>
|
||
</ul>
|
||
<p>You can also <strong>embed a share button</strong> within your game, play around with <strong>custom inline buttons</strong>, <strong>URL parameters</strong> and much more. To get a better idea, make sure to check out:</p>
|
||
<ul>
|
||
<li><a href="/bots/games">HTML5 Games Manual</a></li>
|
||
<li><a href="/bots/api#games">HTML5 Games Bot API Docs</a></li>
|
||
</ul>
|
||
<div>
|
||
<a href="/file/464001558/11b92/y_Fu9QQWtj0.141959/dc9db48f66800bf271" target="_blank"><img src="/file/464001558/11b92/y_Fu9QQWtj0.141959/dc9db48f66800bf271" title="Games" width=50% class="dev_page_image" /></a>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>Check out <a href="https://t.me/gamebot">@GameBot</a> and <a href="https://t.me/gamee">@gamee</a> for examples of what you can do using our Gaming Platform.</p>
|
||
</blockquote>
|
||
<h3><a class="anchor" name="stickers-and-custom-emoji" href="#stickers-and-custom-emoji"><i class="anchor-icon"></i></a>Stickers and Custom Emoji</h3>
|
||
<p><a href="https://core.telegram.org/stickers">Stickers</a> and <a href="https://telegram.org/blog/custom-emoji">Custom Emoji</a> are a distinctive Telegram feature used by millions of users to share artwork every day. Stickers and custom emoji take many forms – ranging from <strong>basic images</strong> to smooth <strong>vector animations</strong> and high-detail <strong>.WEBM videos</strong>.</p>
|
||
<p>All these formats are supported by our <a href="api#stickers">Bot API</a>, which allows bots to <strong>create</strong>, <strong>edit</strong>, <strong>delete</strong> and <strong>share</strong> new artwork packs on the fly. Telegram's <a href="https://core.telegram.org/import-stickers">Import API</a> lets users <strong>migrate packs</strong> from other platforms and sticker apps.</p>
|
||
<p><strong>Creating a new pack</strong><br>To create a <strong>new pack</strong>, simply:</p>
|
||
<ul>
|
||
<li><strong>Prepare</strong> your artwork following our <a href="https://core.telegram.org/stickers">technical requirements</a>.</li>
|
||
<li><strong>Create</strong> a new sticker pack via <a href="api#createnewstickerset">createStickerSet</a>. Set <code>sticker_type</code> to <em>regular</em> to create a sticker pack or to <em>custom emoji</em> to create a pack of custom emoji. Attach the <a href="api#file">files</a> you wish to include in the pack as an array of <a href="https://core.telegram.org/bots#inputsticker">InputSticker</a></li>
|
||
<li>You can use <a href="api#addstickertoset">addStickerToSet</a> to add stickers or emoji later on.</li>
|
||
</ul>
|
||
<p><strong>Additional features</strong><br>Regular stickers and custom emoji support <strong>keywords</strong> that users can type to quickly find the respective artwork – this can be useful when a sticker doesn't have obvious ties to a specific emoji. You can use the <code>keywords</code> parameter in <a href="https://core.telegram.org/bots#inputsticker">InputSticker</a> to specify them.</p>
|
||
<p>Custom emoji additionally support <strong>adaptive colors</strong> – they will always match the current context (e.g., white on photos, accent color when used as status, etc.); to enable this feature, use the <code>needs_repainting</code> parameter in <a href="api#createnewstickerset">createStickerSet</a>.</p>
|
||
<p>Once you're done creating and sharing your artwork, don't forget to check out our <a href="api#stickers">remaining sticker methods</a> to find out how to <a href="api#setstickersetthumb">edit</a>, <a href="api#deletestickerfromset">delete</a> and even <a href="api#setstickerpositioninset">reorder</a> your pack. </p>
|
||
<blockquote>
|
||
<p>Note that these methods will only work on packs <strong>created by the bot that is calling them</strong>.</p>
|
||
</blockquote>
|
||
<h3><a class="anchor" name="language-support" href="#language-support"><i class="anchor-icon"></i></a>Language Support</h3>
|
||
<p>Bots can tailor their interfaces to <strong>support multiple languages</strong> – updating inputs and information on the fly. A user’s <a href="/bots/api#user">language_code</a> is included in every relevant <a href="/bots/api#update">update</a> as an <a href="https://en.wikipedia.org/wiki/IETF_language_tag">IETF language tag</a>, allowing bots to adapt accordingly. </p>
|
||
<p>We recommend that you follow our guidelines to provide <strong>the best user experience</strong>.</p>
|
||
<ul>
|
||
<li>Your interfaces, texts and <a href="/bots/api#answerinlinequery">inline results</a> should adapt seamlessly to the <em>language_code</em>, without user intervention.</li>
|
||
<li>Connected <a href="/bots/webapps">WebApps</a> will receive the user's <em>language_code</em> – your HTML page should account for it.</li>
|
||
<li><a href="/bots/html5-games">HTML5 Games</a> can obtain language information if you specify it as a <a href="/bots/games#using-url-parameters">URL parameter</a>. You can generate this parameter from the <em>language_code</em> field in the <a href="/bots/api#user">User</a> object served with the initial game <a href="/bots/api#callbackquery">CallbackQuery</a>.</li>
|
||
<li>The bot's <strong>Name</strong>, <strong>Description</strong> and <strong>About text</strong> can be natively localized with the respective <a href="https://core.telegram.org/bots/api#setmydescription">methods</a>.</li>
|
||
<li>Command lists can also be specified for individual languages – more on this <a href="#commands">here</a>.</li>
|
||
</ul>
|
||
<div class="blog_video_player_wrap" style="max-width: 400px; margin: 20px auto 20px;">
|
||
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay="" loop="" controls="" muted="" poster="/file/464001822/10cd0/EvtvjnhA-kA.132475/e285952b505535d85a" style="max-width: 400px;" title="Language Support" alt="Video: Language Support">
|
||
<source src="/file/464001083/105cd/NF4ViAHfTJc.3601652.mp4/0fd787953c11a6371d" type="video/mp4">
|
||
</video>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>The <em>language_code</em> is an <strong>optional field</strong> – it could be empty.<br>If you target the general public, your code should always fall back to either the last recorded language tag or English (in this order) when the field is missing for a specific user. </p>
|
||
</blockquote>
|
||
<hr>
|
||
<h3><a class="anchor" name="bot-management" href="#bot-management"><i class="anchor-icon"></i></a>Bot Management</h3>
|
||
<h4><a class="anchor" name="privacy-mode" href="#privacy-mode"><i class="anchor-icon"></i></a>Privacy Mode</h4>
|
||
<p>Bots are frequently added to groups to perform basic tasks or assist moderators – like automatically posting company announcements or even celebrating birthdays. By default, <strong>all bots</strong> added to groups run in Privacy Mode and only see relevant messages and commands:</p>
|
||
<ul>
|
||
<li>Commands explicitly meant for them (e.g., <code>/command@this_bot</code>).</li>
|
||
<li>General commands (e.g. <code>/start</code>) if the bot was the last bot to send a message to the group.</li>
|
||
<li>Inline messages sent <a href="/bots/api#inline-mode">via</a> the bot.</li>
|
||
<li>Replies to any messages implicitly or explicitly meant for this bot.</li>
|
||
</ul>
|
||
<p>All bots will also receive, <strong>regardless of privacy mode</strong>:</p>
|
||
<ul>
|
||
<li>All service messages.</li>
|
||
<li>All messages from private chats.</li>
|
||
<li>All messages from channels where they are a member.</li>
|
||
</ul>
|
||
<p>Privacy mode is <strong>enabled by default</strong> for all bots, except bots that were added to a group as admins (bot admins always receive <strong>all messages</strong>). It can be disabled so that the bot receives all messages like an ordinary user (the bot will need to be re-added to the group for this change to take effect). We only recommend doing this in cases where it is <strong>absolutely necessary</strong> for your bot to work. In most cases, using the force reply option for the bot's messages should be more than enough.</p>
|
||
<div>
|
||
<a href="/file/464001338/107af/JdbERa0BATg.62371/28977e9a96aed3860a" target="_blank"><img src="/file/464001338/107af/JdbERa0BATg.62371/28977e9a96aed3860a" title="Privacy Mode" class="dev_page_image" width=50%/></a>
|
||
</div>
|
||
|
||
<blockquote>
|
||
<p>This mode not only increases user privacy, but also makes the bot more efficient by reducing the number of inputs it needs to process. Users can always see a bot’s current privacy setting in the list of group members.</p>
|
||
</blockquote>
|
||
<h3><a class="anchor" name="testing-your-bot" href="#testing-your-bot"><i class="anchor-icon"></i></a>Testing your bot</h3>
|
||
<p>You can quickly test your bot <strong>without interfering</strong> with its users by simply running another instance of your code on a different bot account. To do so, create a <em>new bot</em> via <a href="https://t.me/botfather">@BotFather</a>, obtain its token and use it in the testing instance of your code.</p>
|
||
<p>All further testing and debugging can happen privately on the new bot, without affecting the original instance.</p>
|
||
<blockquote>
|
||
<p>If you need to share file references across bots, note that the <code>file_id</code> field is tied to a single bot id, so your test instance cannot use a shared <code>file_id</code> database to quickly send media – files must be individually reuploaded.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="dedicated-test-environment" href="#dedicated-test-environment"><i class="anchor-icon"></i></a>Dedicated test environment</h4>
|
||
<p>Telegram also offers a dedicated <strong>test environment</strong> suitable for more advanced testing. Bots and users in this environment generally have more flexible restrictions – for example:</p>
|
||
<ul>
|
||
<li>When working with the test environment, you may use HTTP links without TLS to test your <a href="https://core.telegram.org/bots/features#web-apps">Web Apps</a> or <a href="https://core.telegram.org/bots/features#web-login">Web Login</a>.</li>
|
||
<li>You can test <a href="https://telegram.org/blog/topics-in-groups-collectible-usernames#topics-in-groups">topics</a> without needing 200 users in your group.</li>
|
||
</ul>
|
||
<blockquote>
|
||
<p><strong>Flood limits</strong> are not raised in the test environment, and may at times be stricter. To minimize how this impacts your bot, you should make sure that it handles errors with retry policies and does not depend on hardcoded limit values.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="creating-a-bot-in-the-test-environment" href="#creating-a-bot-in-the-test-environment"><i class="anchor-icon"></i></a>Creating a bot in the test environment</h4>
|
||
<p>The test environment is <strong>completely separate</strong> from the main environment, so you will need to create a new user account and a new bot with <a href="https://t.me/botfather">@BotFather</a>.</p>
|
||
<p>To create an account and log in, use either of the following:</p>
|
||
<ul>
|
||
<li><strong>iOS</strong>: tap 10 times on the Settings icon > Accounts > Login to another account > Test.</li>
|
||
<li><strong>Telegram Desktop</strong>: open ☰ Settings > Shift + Alt + Right click 'Add Account' and select 'Test Server'.</li>
|
||
<li><strong>macOS</strong>: click the Settings icon 10 times to open the Debug Menu, ⌘ + click 'Add Account' and log in via phone number.</li>
|
||
</ul>
|
||
<p>After logging in, simply <a href="#creating-a-new-bot">create a new bot</a> following the standard procedure and send your requests to the Test Bot API in this format:</p>
|
||
<pre><code>https://api.telegram.org/bot<token>/test/METHOD_NAME</code></pre>
|
||
<blockquote>
|
||
<p>When working with the test environment, you may use HTTP links without TLS in the <code>url</code> field of both <a href="/bots/api#loginurl">LoginUrl</a> and <a href="/bots/api#webappinfo">WebAppInfo</a>.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="status-alerts" href="#status-alerts"><i class="anchor-icon"></i></a>Status alerts</h4>
|
||
<p>Millions choose Telegram for its speed. To best benefit users, your bot also <strong>needs to be responsive</strong>. In order to help developers keep their bots in shape, <a href="https://t.me/botfather">@BotFather</a> will send <strong>status alerts</strong> if it sees something is wrong.</p>
|
||
<p>We check the number of replies and the <em>request/response</em> conversion rate for popular bots (~300 requests per minute, this value may change in the future). If your bot returns an <strong>abnormally low number</strong>, you will receive a notification from <a href="https://t.me/botfather">@BotFather</a>.</p>
|
||
<h5><a class="anchor" name="responding-to-alerts" href="#responding-to-alerts"><i class="anchor-icon"></i></a>Responding to alerts</h5>
|
||
<p>By default, <strong>you will only get one alert per bot per hour</strong>. </p>
|
||
<p>Each alert has the following buttons:</p>
|
||
<ul>
|
||
<li><strong>Fixed</strong> - Use this if you found an issue with your bot and fixed it. If you press the fix button, we will resume sending alerts in the regular way so that you can see if your fix worked within 5-10 minutes instead of having to wait for an hour.</li>
|
||
<li><strong>Support</strong> - Use this to open a chat with <a href="https://t.me/botsupport">@BotSupport</a> if you don't see any issues with your bot or if you think the problem is on our side.</li>
|
||
<li><strong>Mute for 8h/1w</strong> - Use this if you can't fix your bot at the moment. This will disable all alerts for the bot in question for the specified period of time. <strong>We do not recommend</strong> using this option since your users may migrate to a more stable bot. You can unmute alerts in your bot's settings via <a href="https://t.me/botfather">@BotFather</a>.</li>
|
||
</ul>
|
||
<h5><a class="anchor" name="monitored-issues" href="#monitored-issues"><i class="anchor-icon"></i></a>Monitored issues</h5>
|
||
<p>We currently notify you about the following issues:</p>
|
||
<ul>
|
||
<li><p><strong>Too few private messages are sent.</strong> Value: <strong>{value}</strong> - Your bot is sending far fewer messages than it did in previous weeks. This is useful for newsletter-style bots that send messages without prompts from users. The larger the value, the more significant the difference.</p>
|
||
</li>
|
||
<li><p><strong>Too few replies to incoming private messages</strong>. Conversion rate: <strong>{value}</strong> - Your bot is not replying to all messages that are being sent to it (the request/response conversion rate for your bot was too low for at least two of the last three 5-minute periods). </p>
|
||
</li>
|
||
</ul>
|
||
<blockquote>
|
||
<p>To provide a good user experience, please respond to all messages that are sent to your bot. Respond to message updates by calling send… methods (e.g. <a href="/bots/api#sendmessage">sendMessage</a>).</p>
|
||
</blockquote>
|
||
<ul>
|
||
<li><strong>Too few answers to inline queries</strong>. Conversion rate: <strong>{value}</strong> - Your bot is not replying to all inline queries that are being sent to it, calculated in the same way as above. Respond to <code>inline_query</code> updates by calling <a href="/bots/api#answerinlinequery">answerInlineQuery</a>.</li>
|
||
</ul>
|
||
<ul>
|
||
<li><strong>Too few answers to callback queries</strong>. Conversion rate: <strong>{value}</strong></li>
|
||
<li><strong>Too few answers to callback game queries</strong>. Conversion rate: <strong>{value}</strong> - Your bot is not replying to all callback queries that are being sent to it (with or without games), calculated in the same way as above. Respond to <code>callback_query</code> updates by calling <a href="/bots/api#answercallbackquery">answerCallbackQuery</a>.</li>
|
||
</ul>
|
||
<h4><a class="anchor" name="local-bot-api" href="#local-bot-api"><i class="anchor-icon"></i></a>Local Bot API</h4>
|
||
<p>You can host and work with <strong>your own instance</strong> of our open-source <a href="/bots/api">Bot API</a>.<br>The <strong>source code</strong> is available <a href="https://github.com/tdlib/telegram-bot-api">here</a>, along with a quick <a href="https://github.com/tdlib/telegram-bot-api#installation">installation guide</a>.</p>
|
||
<p>After <strong>installing the server</strong>, remember to use the <a href="/bots/api#logout">logOut</a> method before <strong>redirecting requests</strong> to your new local API URL.</p>
|
||
<blockquote>
|
||
<p>Your local instance runs on port <code>8081</code> by default and will only accept HTTP requests, so a TLS termination proxy has to be used to handle remote HTTPS requests.</p>
|
||
</blockquote>
|
||
<p>By hosting our API locally you'll gain access to <strong>some upgrades</strong>, including:</p>
|
||
<table class="table">
|
||
<thead>
|
||
<tr>
|
||
<th>API</th>
|
||
<th>Max File Download</th>
|
||
<th>Max File Upload</th>
|
||
<th>WHook URL</th>
|
||
<th>WHook Port</th>
|
||
<th>WHook Max Connections</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><a href="/bots/api#making-requests">Official</a></td>
|
||
<td>20MB</td>
|
||
<td>50MB</td>
|
||
<td>HTTPS</td>
|
||
<td>443,80,88,8443</td>
|
||
<td>1-100</td>
|
||
</tr>
|
||
<tr>
|
||
<td><a href="/bots/api#using-a-local-bot-api-server">Local</a></td>
|
||
<td>Unlimited</td>
|
||
<td>2000MB</td>
|
||
<td>HTTP</td>
|
||
<td>Any port</td>
|
||
<td>1-100000</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<blockquote>
|
||
<p>You can find an exhaustive list <a href="/bots/api#using-a-local-bot-api-server">here</a>.<br>All limits may be subject to change in the future, so make sure to follow <a href="https://t.me/botnews">@BotNews</a>.</p>
|
||
</blockquote>
|
||
<hr>
|
||
<h3><a class="anchor" name="botfather" href="#botfather"><i class="anchor-icon"></i></a>BotFather</h3>
|
||
<p>Below is a detailed guide to using <a href="https://t.me/botfather">@BotFather</a>, Telegram’s tool for <strong>creating</strong> and <strong>managing</strong> bots.</p>
|
||
<h4><a class="anchor" name="creating-a-new-bot" href="#creating-a-new-bot"><i class="anchor-icon"></i></a>Creating a new bot</h4>
|
||
<p>Use the <code>/newbot</code> command to create a new bot. <a href="https://t.me/botfather">@BotFather</a> will ask you for a name and username, then generate an authentication token for your new bot.</p>
|
||
<ul>
|
||
<li><p>The <strong>name</strong> of your bot is displayed in contact details and elsewhere.</p>
|
||
</li>
|
||
<li><p>The <strong>username</strong> is a short name, used in search, mentions and t.me links. Usernames are 5-32 characters long and not case sensitive – but may only include Latin characters, numbers, and underscores. Your bot's username must end in 'bot’, like 'tetris_bot' or 'TetrisBot'.</p>
|
||
</li>
|
||
<li><p>The <strong>token</strong> is a string, like <code>110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw</code>, which is required to authorize the bot and send requests to the Bot API. Keep your token secure and store it safely, it can be used by anyone to control your bot. </p>
|
||
</li>
|
||
</ul>
|
||
<blockquote>
|
||
<p>Unlike the bot’s name, the username cannot be changed later – so choose it carefully.<br>When sending a request to api.telegram.org, remember to prefix the word ‘bot’ to your token.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="about-text-description-and-profile-media" href="#about-text-description-and-profile-media"><i class="anchor-icon"></i></a>About text, description and profile media</h4>
|
||
<p>When new users open your bot, they will be met with a helpful description in a box titled “What can this bot do?”.</p>
|
||
<p>Properly <a href="#edit-bots">setting this field</a> in <a href="https://t.me/botfather">@BotFather</a> allows everyone to immediately get an idea of what your bot can do – your description should be <strong>brief</strong>, <strong>to the point</strong> and <strong>on topic</strong>.</p>
|
||
<blockquote>
|
||
<p>You can also add a photo or video to this field with <code>Edit Description Picture</code> in <a href="https://t.me/botfather">@BotFather</a>.</p>
|
||
</blockquote>
|
||
<p>Additionally, just like normal users, bots also come with a <strong>short bio</strong> available on their profile. If you didn't specify this field while first creating your bot, you can set it at any time with the <code>/setabouttext</code> command in <a href="https://t.me/botfather">@BotFather</a>. Users can interact with many bots and they won't have access to their description after starting them – having a quick reminder of the bot's purpose can be very useful.</p>
|
||
<blockquote>
|
||
<p>Note that both the <strong>Description</strong> and the <strong>About text</strong> can be <a href="https://core.telegram.org/bots/api#setmydescription">natively localized</a> – each user will automatically see the correct translation for their language.</p>
|
||
</blockquote>
|
||
<p>Bots can also have a <strong>profile picture</strong> – you should pick something unique and original so that users can find it in their chat list at a glance.</p>
|
||
<blockquote>
|
||
<p>Starting from April 21, 2023 (<a href="https://telegram.org/blog/shareable-folders-custom-wallpapers">Telegram 9.6</a>), you can edit your bot directly from its profile page – including setting a custom <strong>profile video</strong>.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="generating-an-authentication-token" href="#generating-an-authentication-token"><i class="anchor-icon"></i></a>Generating an authentication token</h4>
|
||
<p>If your existing token is <strong>compromised</strong> or <strong>you lost it</strong> for some reason, use the <code>/token</code> command to generate a new one.</p>
|
||
<h4><a class="anchor" name="transfer-ownership" href="#transfer-ownership"><i class="anchor-icon"></i></a>Transfer ownership</h4>
|
||
<p>You can transfer ownership of your bot <strong>to another user</strong>.<br>To do this, send <code>/mybots</code>, select your bot, then <em>transfer ownership</em>.<br>You can only transfer a bot to users who have interacted with it at least once.</p>
|
||
<blockquote>
|
||
<p>Transferring ownership will give full control of the bot to another user – they will be able to access the bot’s messages and even delete it. The transfer is permanent, so please consider it carefully.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="botfather-commands" href="#botfather-commands"><i class="anchor-icon"></i></a>BotFather commands</h4>
|
||
<p>The remaining commands are pretty self-explanatory:</p>
|
||
<ul>
|
||
<li>/mybots – returns a list of your bots with handy controls to edit their settings.</li>
|
||
<li>/mygames – does the same for your games.</li>
|
||
</ul>
|
||
<h4><a class="anchor" name="edit-bots" href="#edit-bots"><i class="anchor-icon"></i></a>Edit bots</h4>
|
||
<p>To edit your bot, you have two options.</p>
|
||
<p>You can use the available commands:</p>
|
||
<ul>
|
||
<li>/setname – change your bot's <strong>name</strong>.</li>
|
||
<li>/setdescription – change the bot's <strong>description</strong> (short text up to 512 characters). Users will see this text at the beginning of the conversation with the bot, titled '<em>What can this bot do?</em>'.</li>
|
||
<li>/setabouttext – change the bot's <strong>about info</strong>, a shorter text up to 120 characters. Users will see this text on the bot's profile page. When they share your bot with someone, this text is sent together with the link.</li>
|
||
<li>/setuserpic – change the bot's <strong>profile picture</strong>. </li>
|
||
<li>/setcommands – change the list of <strong>commands</strong> supported by your bot. Users will see these commands as suggestions when they type <code>/</code> in the chat with your bot. See <a href="#commands">commands</a> for more info.</li>
|
||
<li>/setdomain – link a <strong>website domain</strong> to your bot. See the <a href="#login-widget">login widget</a> section.</li>
|
||
<li>/deletebot – delete your bot and <strong>free its username</strong>. Cannot be undone.</li>
|
||
</ul>
|
||
<p>Or you can use the <code>/mybots</code> command, tap on your bot and use the modern inline interface to edit it.</p>
|
||
<blockquote>
|
||
<p>Starting from April 21, 2023 (<a href="https://telegram.org/blog/shareable-folders-custom-wallpapers">Telegram 9.6</a>), you can edit your bot's public-facing info directly from its profile page – including setting a custom <strong>profile video</strong>.</p>
|
||
</blockquote>
|
||
<h4><a class="anchor" name="edit-settings" href="#edit-settings"><i class="anchor-icon"></i></a>Edit settings</h4>
|
||
<ul>
|
||
<li>/setinline – toggle <strong>inline mode</strong> for your bot.</li>
|
||
<li>/setinlinegeo – request <strong>location data</strong> to provide location-based inline results.</li>
|
||
<li>/setjoingroups – toggle whether your bot can be <strong>added to groups</strong> or not. All bots must be able to process direct messages, but if your bot was not designed to work in groups, you can disable this.</li>
|
||
<li>/setinlinefeedback – toggle whether the API should <strong>send updates about the results</strong> chosen by users. See an in-depth explanation <a href="/bots/inline#collecting-feedback">here</a>.</li>
|
||
<li>/setprivacy – set which messages your bot will receive when added to a group. See <a href="#privacy-mode">privacy-mode</a> for more info.</li>
|
||
</ul>
|
||
<h4><a class="anchor" name="manage-games" href="#manage-games"><i class="anchor-icon"></i></a>Manage games</h4>
|
||
<ul>
|
||
<li>/newgame – create a new game.</li>
|
||
<li>/listgames – see a list of your games.</li>
|
||
<li>/editgame – edit a game.</li>
|
||
<li>/deletegame – delete an existing game.</li>
|
||
</ul>
|
||
<blockquote>
|
||
<p>Please note that it may take a few minutes for changes to take effect.</p>
|
||
</blockquote>
|
||
<hr>
|
||
<p>With this information, you are ready to proceed to our <a href="/bots/api">Full API Reference for Developers</a>.</p>
|
||
<ul>
|
||
<li>If you have any questions, check out our <a href="/bots/faq">Bot FAQ</a>.</li>
|
||
<li>If you're experiencing issues with our API, please contact <a href="https://t.me/botsupport">@BotSupport</a> on Telegram.</li>
|
||
</ul>
|
||
</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/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?47"></script>
|
||
<script src="/js/jquery.min.js?1"></script>
|
||
<script src="/js/bootstrap.min.js?1"></script>
|
||
|
||
<script>window.initDevPageNav&&initDevPageNav();
|
||
initScrollVideos(true);
|
||
backToTopInit("Go up");
|
||
removePreloadInit();
|
||
</script>
|
||
</body>
|
||
</html>
|
||
|