telegram-crawler/data/web/blogfork.telegram.org/bots.html
2024-11-17 11:50:35 +00:00

278 lines
21 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="">
<head>
<meta charset="utf-8">
<title>Bots: An introduction for developers</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="description" content="Bots are small applications that run entirely within the Telegram app. Users interact with bots through flexible interfaces…">
<meta property="og:title" content="Bots: An introduction for developers">
<meta property="og:image" content="75f7c457f2561cbf84">
<meta property="og:description" content="Bots are small applications that run entirely within the Telegram app. Users interact with bots through flexible interfaces…">
<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?241" 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">Bots: An introduction for developers</h1>
<div id="dev_page_content"><!-- scroll_nav -->
<p>Bots are <strong>small applications</strong> that run entirely within the Telegram app. Users interact with bots through <strong>flexible interfaces</strong> that can support <strong>any kind of task or service</strong>. For more information, see:</p>
<ul>
<li><a href="/bots/features">Detailed Guide to Bot Features</a></li>
<li><a href="/bots/api">Full API Reference for Developers</a></li>
<li><a href="/bots/tutorial">Basic Tutorial: From @BotFather to &#39;Hello World&#39;</a></li>
</ul>
<p>The <strong>Telegram Bot Platform</strong> hosts more than <strong>10 million</strong> bots and is <strong>free</strong> for both users and developers.</p>
<h3><a class="anchor" name="what-can-you-do-with-bots" href="#what-can-you-do-with-bots"><i class="anchor-icon"></i></a>What Can You Do with Bots?</h3>
<ul>
<li><a href="#replace-entire-websites">Replace Entire Websites</a></li>
<li><a href="#manage-your-business">Manage Your Business</a></li>
<li><a href="#receive-payments">Receive Payments</a></li>
<li><a href="#create-custom-tools">Create Custom Tools</a></li>
<li><a href="#integrate-with-services-and-devices">Integrate with Services and Devices</a></li>
<li><a href="#host-games">Host Games</a></li>
<li><a href="#build-social-networks">Build Social Networks</a></li>
<li><a href="#monetize-your-project">Monetize Your Project</a></li>
<li><a href="#anything-else">Anything Else!</a></li>
</ul>
<h4><a class="anchor" name="replace-entire-websites" href="#replace-entire-websites"><i class="anchor-icon"></i></a>Replace Entire Websites</h4>
<p>Telegram bots can host <a href="/bots/webapps">Mini Apps</a> built with <em>JavaScript</em>. This allows for <strong>infinitely flexible</strong> interfaces that can power everything from online stores to arcade games. Unlike websites, bots support <a href="/api/url-authorization">seamless authorization</a> and notifications through Telegram out of the box.</p>
<div class="blog_video_player_wrap" style="max-width: 600px; 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: 600px;" title="" alt="Bot Revolution">
<source src="/file/464001679/11aa9/KQx_BlPVXRo.4922145.mp4/c65433c8ac11a347a8" type="video/mp4">
</video>
</div>
<blockquote>
<p>Try <a href="https://t.me/durgerkingbot">@DurgerKingBot</a> or check out the <a href="/bots/webapps">dedicated guide to Web Apps</a> to build your own.</p>
</blockquote>
<h4><a class="anchor" name="manage-your-business" href="#manage-your-business"><i class="anchor-icon"></i></a>Manage Your Business</h4>
<p><a href="https://telegram.org/blog/telegram-business">Telegram Business</a> users can connect Telegram bots to process and answer messages <strong>on their behalf</strong>, via their personal account. This allows businesses to <strong>seamlessly integrate</strong> any existing tools and workflows, or add new AI assistants to <strong>increase productivity</strong>.</p>
<p>As we continue to expand the set of <strong>free tools</strong> <a href="https://core.telegram.org/bots">available to bots</a> through this integration, we encourage all developers to <strong>innovate</strong> and <strong>develop</strong> useful applications and services for <strong>businesses</strong> on Telegram.</p>
<div class="blog_video_player_wrap" style="max-width: 600px; margin: 20px auto 20px;">
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay loop controls muted poster="/file/400780400238/1/x875tPT245w.58064/1b426d3eda0a923c03" style="max-width: 600px;" title="" alt="">
<source src="/file/400780400382/1/BVN6m4W5a6w.4289566.mp4/9dc47caab261eaade4" type="video/mp4">
</video>
</div>
<blockquote>
<p>Developers can turn on <a href="https://core.telegram.org/bots/features#bots-for-business">Business Mode</a> in <a href="https://t.me/BotFather">@BotFather</a> if their bot supports <a href="https://core.telegram.org/bots/api#businessconnection">integration</a> with Telegram Business accounts.</p>
</blockquote>
<h5><a class="anchor" name="receive-payments" href="#receive-payments"><i class="anchor-icon"></i></a>Receive Payments</h5>
<p>Bots can sell all kinds of goods and services on Telegram to anyone in the world. <a href="https://telegram.org/blog/telegram-stars">Telegram Stars</a> allow users to securely and effortlessly buy <strong>digital products</strong> via in-app purchases. In addition, <strong>physical products</strong> can be purchased through more than 20 <a href="https://core.telegram.org/bots/payments#supported-payment-providers">integrated payment providers</a>.</p>
<div class="blog_video_player_wrap" style="max-width: 600px; margin: 20px auto 20px;">
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay loop controls muted poster="/file/400780400936/3/oM0NSZq-c-U.70843/aabc7c9f3196368434" style="max-width: 600px;" title="" alt="">
<source src="/file/400780400194/6/alSNP8Zj18E.7354629.mp4/96b4d26b22e610c8bd" type="video/mp4">
</video>
</div>
<blockquote>
<p>Try <a href="https://t.me/shopbot">@ShopBot</a> or check out our dedicated guides for <a href="https://core.telegram.org/bots/payments-stars">digital</a> and <a href="https://core.telegram.org/bots/payments">physical</a> products to build your own.</p>
</blockquote>
<h4><a class="anchor" name="create-custom-tools" href="#create-custom-tools"><i class="anchor-icon"></i></a>Create Custom Tools</h4>
<p>Increase your productivity by creating bots for <strong>specific tasks</strong> like converting files, managing chats or fetching todays forecast. Users can chat directly with bots, or add them to groups and channels to introduce extra features.</p>
<div class="blog_video_player_wrap" style="max-width: 600px; margin: 20px auto 20px;">
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay loop controls muted poster="/file/464001084/12c1d/eNLdXm8moqA.134736/e28dd8ea6d49eee57d" style="max-width: 600px;" title="" alt="">
<source src="/file/464001127/10a99/GC0dSHYQTb0.3621529.mp4/75439f14147e13b6fb" type="video/mp4">
</video>
</div>
<blockquote>
<p>Mini apps can generate media and files that users can effortlessly share to <a href="webapps#sharing-media">other chats</a> or a post <a href="webapps#sharing-from-mini-apps-to-stories">as a story</a>.</p>
</blockquote>
<h4><a class="anchor" name="integrate-with-services-and-devices" href="#integrate-with-services-and-devices"><i class="anchor-icon"></i></a>Integrate with Services and Devices</h4>
<p>Mini apps can <strong>seamlessly integrate</strong> with third-party services, APIs and devices to instantly process and update information like changing a user&#39;s <a href="webapps#setting-emoji-status">emoji status</a> when they start a game <img class="emoji" src="//telegram.org/img/emoji/40/F09F8EAE.png" width="20" height="20" alt="🎮" /> or get in a taxi <img class="emoji" src="//telegram.org/img/emoji/40/F09F9A95.png" width="20" height="20" alt="🚕" />.</p>
<div class="blog_video_player_wrap" style="max-width: 600px; margin: 20px auto 20px;">
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay loop controls muted poster="/file/400780400471/4/NxjzOa07Eyc.38651/62c7f445e0e06a4452" style="max-width: 600px;" title="">
<source src="/file/400780400995/4/5X1SreBoHEY.1731682.mp4/0e2f79c91e61b21b58" type="video/mp4">
</video>
</div>
<blockquote>
<p>By default, Mini Apps seamlessly integrate with Android and iOS, allowing users to add <a href="https://telegram.org/blog/fullscreen-miniapps-and-more#home-screen-shortcuts">direct shortcuts</a> to their devices home screen.</p>
</blockquote>
<p>Likewise, many popular platforms already have official Telegram bots, which allow users to comfortably access content in one app or perform quick searches using <a href="/bots/inline">inline mode</a>.</p>
<div style="max-width: 600px; margin: 20px auto 20px;">
<a href="/file/464001186/11e04/7XO37b9iccE.133932/a29f8bf593af567fcc" target="_blank"><img src="/file/464001186/11e04/7XO37b9iccE.133932/a29f8bf593af567fcc" title="" class="dev_page_image" style="max-width: 600px;" /></a>
</div>
<blockquote>
<p>Try <a href="https://t.me/gmailbot">@GMailBot</a>, <a href="https://t.me/githubbot">@GitHubBot</a>, <a href="https://t.me/bing">@Bing</a>, <a href="https://t.me/youtube">@YouTube</a>, <a href="https://t.me/wiki">@wiki</a> and more.</p>
</blockquote>
<h4><a class="anchor" name="host-games" href="#host-games"><i class="anchor-icon"></i></a>Host Games</h4>
<p>Developers can create both lightweight <a href="/bots/games">HTML5 Games</a> and immersive <strong>full-screen modern games</strong> with support for <a href="webapps#accelerometer">detailed motion controls</a>, location-based <a href="webapps#locationmanager">points of interest</a> and dynamic <a href="webapps#additional-data-in-user-agent">hardware optimizations</a>.</p>
<div class="blog_video_player_wrap" style="max-width: 600px; margin: 20px auto 20px;">
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay loop controls muted poster="/file/400780400417/2/RaXcGRNXC0g.97571/e112d0d114f083f9b7" style="max-width: 600px;" title="" alt="">
<source src="/file/400780400950/2/822tco9D7ig.4744195.mp4/7581b18200d67c56a6" type="video/mp4">
</video>
</div>
<blockquote>
<p>Try some of the games in the <a href="https://t.me/gamee">@Gamee</a> library or check out the <a href="/bots/games">HTML5</a> and <a href="webapps">Mini App</a> manuals to build your own. </p>
</blockquote>
<h4><a class="anchor" name="build-social-networks" href="#build-social-networks"><i class="anchor-icon"></i></a>Build Social Networks</h4>
<p>Bots can serve as an intermediary to connect users based on shared interests, location, and more. Coordinate meetups, show local services, or help people sell second-hand items.</p>
<div class="blog_video_player_wrap" style="max-width: 600px; margin: 20px auto 20px;">
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay loop controls muted poster="/file/464001041/10ebf/BPN6BLcuS8I.137509/fd81647baa51b928a2" style="max-width: 600px;" title="" alt="">
<source src="/file/464001262/106bf/TVxoe4U0kIY.2116862.mp4/db7dfd397afbe2a61c" type="video/mp4">
</video>
</div>
<blockquote>
<p>Users can place <a href="https://telegram.org/blog/fullscreen-miniapps-and-more#home-screen-shortcuts">direct shortcuts</a> to specific mini apps on the <strong>home screen</strong> of their devices accessing services in <strong>one tap</strong>.</p>
</blockquote>
<h4><a class="anchor" name="monetize-your-project" href="#monetize-your-project"><i class="anchor-icon"></i></a>Monetize Your Project</h4>
<p>Telegram offers a <strong>robust ecosystem</strong> of monetization features, allowing any bot to support its development with <strong>multiple revenue streams</strong>. Popular bots can passively earn income through <a href="https://telegram.org/blog/dynamic-video-quality-and-more#telegram-ads-in-bots">Revenue Sharing</a> from Telegram Ads, implement <a href="https://telegram.org/blog/fullscreen-miniapps-and-more#subscription-plans">subscription plans</a> for users or offer <a href="https://telegram.org/blog/superchannels-star-reactions-subscriptions#paid-media-for-bots">paid content</a> and <a href="https://telegram.org/blog/telegram-stars#telegram-stars">digital products</a> for <a href="https://telegram.org/blog/telegram-stars">Telegram Stars</a>.</p>
<div class="blog_video_player_wrap" style="max-width: 600px; margin: 20px auto 20px;">
<video class="blog_video_player tl_blog_vid_autoplay" onclick="videoTogglePlay(this)" autoplay loop controls muted poster="/file//file/400780400439/3/fsIQBVDv8iM.42498/fb93eac0593624c6ff" style="max-width: 600px;" title="">
<source src="/file/400780400502/3/yVyvz2IBzwk.3397983.mp4/b34526a4a87a0e18cc" type="video/mp4">
</video>
</div>
<blockquote>
<p>Telegram Stars in your bot&#39;s balance can be used to <a href="https://telegram.org/blog/dynamic-video-quality-and-more#increased-message-limits-for-bots">increase message limits</a>, <a href="https://core.telegram.org/bots/api#sendgift">send gifts</a> to users or <a href="https://telegram.org/blog/monetization-for-channels">accept rewards</a> in Toncoin.</p>
</blockquote>
<h4><a class="anchor" name="anything-else" href="#anything-else"><i class="anchor-icon"></i></a>Anything Else</h4>
<p>The possibilities for bots are endless from simple scripts to complex mini apps. Whether youre a beginner or professional programmer, you can create personalized tools with the help of the <a href="/bots/api">Bot Platform</a>.</p>
<blockquote>
<p>All Mini Apps you build on Telegram can be <strong>highly customized</strong> to fit your brand identity, including by uploading high-quality <a href="#mini-app-previews">media demos</a> and setting a custom <a href="#customizable-loading-screen">Loading Screen</a> with your own logo and color palette</p>
</blockquote>
<hr>
<h3><a class="anchor" name="how-do-bots-work" href="#how-do-bots-work"><i class="anchor-icon"></i></a>How Do Bots Work?</h3>
<blockquote>
<p>For a detailed explanation of Bot Features, see <a href="/bots/features">this guide</a> </p>
</blockquote>
<p>Telegram bots are special accounts that do not need a phone number to set up. Bots are connected to their owners server, which processes inputs and requests from users.</p>
<p>Telegrams intermediary server handles all encryption and communication with the Telegram API. Developers communicate with this server via an easy HTTPS-interface with a simplified version of the <a href="/api">Telegram API</a> known as the <a href="/bots/api">Bot API</a>.</p>
<h4><a class="anchor" name="how-are-bots-different-from-users" href="#how-are-bots-different-from-users"><i class="anchor-icon"></i></a>How Are Bots Different from Users?</h4>
<p>Bots are able to process inputs and requests in ways that user accounts cant, but there are several differences between a bot and a normal user.</p>
<ul>
<li>Bots dont have last seen or online statuses instead they show a bot label in the chat.</li>
<li>Bots have limited cloud storage older messages may be removed by the server shortly after they have been processed.</li>
<li>Bots can&#39;t start conversations with users. A user must either add them to a group or send them a message first. People can search for your bots username or start a chat via its unique t.me/bot_username link.</li>
<li>By default, bots added to groups <strong>only see relevant messages</strong> in the chat (see <a href="/bots/features#privacy-mode">Privacy Mode</a>).</li>
<li>Bots never eat, sleep or complain (unless expressly programmed otherwise).</li>
</ul>
<h4><a class="anchor" name="bot-links" href="#bot-links"><i class="anchor-icon"></i></a>Bot Links</h4>
<p>Bot usernames normally require a bot suffix, but some bots dont have them such as <a href="https://t.me/stickers">@stickers</a>, <a href="https://t.me/gif">@gif</a>, <a href="https://t.me/wiki">@wiki</a> or <a href="https://t.me/bing">@bing</a>. </p>
<p>Anyone can <a href="https://telegram.org/blog/shareable-folders-custom-wallpapers#bot-links-and-telegram-premium-on-fragment">assign collectible usernames</a> to bots, including those without the &#39;bot&#39; suffix.</p>
<h3><a class="anchor" name="how-do-i-create-a-bot" href="#how-do-i-create-a-bot"><i class="anchor-icon"></i></a>How Do I Create a Bot?</h3>
<p>Creating Telegram bots is super-easy, but you will need at least some skills in <strong>computer programming</strong>. </p>
<p>Creating a bot is streamlined by Telegrams Bot API, which gives the tools and framework required to integrate your code. To get started, message <a href="https://t.me/botfather">@BotFather</a> on Telegram to register your bot and receive its authentication token.</p>
<blockquote>
<p>Your <strong>bot token</strong> is its unique identifier store it in a <strong>secure place</strong>, and only share it with people who need direct access to the bot. Everyone who has your token will have <strong>full control</strong> over your bot.</p>
</blockquote>
<h4><a class="anchor" name="what-next" href="#what-next"><i class="anchor-icon"></i></a>What Next?</h4>
<p>We recommend that you check out our guide to <a href="/bots/features">Bot Features</a> to see what you can teach your bot to do:</p>
<ul>
<li><a href="/bots/features">Detailed Guide to Bot Features</a></li>
<li><a href="/bots/api">Full API Reference for Developers</a></li>
<li><a href="/bots/tutorial">Basic Tutorial: From @BotFather to &#39;Hello World&#39;</a></li>
<li><a href="/bots/samples">Code Examples</a></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="//telegram.org/press">Press</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>