Update content of files

This commit is contained in:
GitHub Action 2022-06-21 09:12:18 +00:00
parent cca1cffe60
commit 66b466e789
8 changed files with 1242 additions and 60 deletions

View file

@ -54,6 +54,43 @@ To learn how to create…">
<blockquote>
<p>Subscribe to <a href="https://t.me/botnews">@BotNews</a> to be the first to know about the latest updates and join the discussion in <a href="https://t.me/bottalk">@BotTalk</a></p>
</blockquote>
<h3><a class="anchor" name="june-20-2022" href="#june-20-2022"><i class="anchor-icon"></i></a>June 20, 2022</h3>
<p><strong>Bot API 6.1</strong></p>
<p><strong>Media in Descriptions</strong></p>
<ul>
<li>Added support for photos and videos in the &#39;What can this bot do?&#39; section (shown on the bot&#39;s start screen). Use <a href="https://t.me/BotFather">BotFather</a> to set up media.</li>
</ul>
<p><strong>Web App Improvements</strong></p>
<ul>
<li>Added the fields <em>version</em>, <em>headerColor</em>, <em>backgroundColor</em>, <em>BackButton</em>, <em>HapticFeedback</em> and the methods <em>isVersionAtLeast</em>, <em>setHeaderColor</em>, <em>setBackgroundColor</em>, <em>openLink</em>, <em>openTelegramLink</em>, <em>openInvoice</em> to the class <a href="/bots/webapps#initializing-web-apps">WebApp</a>.</li>
<li>Added the field <em>secondary_bg_color</em> to the class <a href="/bots/webapps#themeparams">ThemeParams</a>.</li>
<li>Added the method <em>offClick</em> to the class <a href="/bots/webapps#mainbutton">MainButton</a>.</li>
<li>Added the fields <em>chat</em>, <em>can_send_after</em> to the class <a href="/bots/webapps#webappinitdata">WebAppInitData</a>.</li>
<li>Added the events <em>backButtonClicked</em>, <em>settingsButtonClicked</em>, <em>invoiceClosed</em>.</li>
</ul>
<p><strong>Join Requests &amp; Payments</strong></p>
<ul>
<li>Added the fields <em>join_to_send_messages</em> and <em>join_by_request</em> to the class <a href="/bots/api#chat">Chat</a>.</li>
<li>Added the ability to process join requests which were created <a href="https://telegram.org/blog/700-million-and-premium#join-requests-for-public-groups">without an invite link</a>. Bots will receive a “chat_join_request” update as usual.</li>
<li>Added the method <a href="/bots/api#createinvoicelink">createInvoiceLink</a> to generate an HTTP link for an invoice.</li>
</ul>
<p><strong>Telegram Premium Support</strong> (<a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">more info</a>)</p>
<ul>
<li>The maximum value of the field <em>file_size</em> in the classes <a href="/bots/api#animation">Animation</a>, <a href="/bots/api#audio">Audio</a>, <a href="/bots/api#document">Document</a>, <a href="/bots/api#video">Video</a>, <a href="/bots/api#voice">Voice</a>, and <a href="/bots/api#file">File</a> can no longer be stored in a signed 32-bit integer type. This change is necessary to support 4GB files uploaded by <a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">premium accounts</a>.</li>
<li>Added the field <em>is_premium</em> to the class <a href="/bots/api#user">User</a>.</li>
<li>Added the field <em>premium_animation</em> to the class <a href="/bots/api#sticker">Sticker</a>.</li>
</ul>
<p><strong>Attachment Menu Integration</strong></p>
<ul>
<li>Added the field <em>added_to_attachment_menu</em> to the class <a href="/bots/api#user">User</a>.</li>
<li>Bots integrated in the attachment menu can now be used in groups, supergroups and channels.</li>
<li>Added support for t.me links that can be used to select the chat in which the attachment menu with the bot will be opened.</li>
</ul>
<p><strong>Other Changes</strong></p>
<ul>
<li>Added the parameter <em>secret_token</em> to the method <a href="/bots/api#setwebhook">setWebhook</a>.</li>
<li>As previously announced, only HTTPS links are now allowed in <em>login_url</em> inline keyboard buttons.</li>
</ul>
<h3><a class="anchor" name="april-16-2022" href="#april-16-2022"><i class="anchor-icon"></i></a>April 16, 2022</h3>
<p><strong>Bot API 6.0</strong></p>
<ul>

View file

@ -56,6 +56,19 @@
<p>To see a <strong>Web App</strong> in action, try our sample <a href="https://t.me/durgerkingbot">@DurgerKingBot</a>.</p>
</blockquote>
<hr>
<h3><a class="anchor" name="recent-changes" href="#recent-changes"><i class="anchor-icon"></i></a>Recent changes</h3>
<h4><a class="anchor" name="june-20-2022" href="#june-20-2022"><i class="anchor-icon"></i></a>June 20, 2022</h4>
<p><strong>Bot API 6.1</strong></p>
<ul>
<li>Added the ability to use bots added to the attachment menu in group, supergroup and channel chats.</li>
<li>Added support for <a href="#adding-bots-to-the-attachment-menu">t.me links</a> that can be used to select the chat in which the attachment menu with the bot will be opened.</li>
<li>Added the fields <em>version</em>, <em>headerColor</em>, <em>backgroundColor</em>, <em>BackButton</em>, <em>HapticFeedback</em> and the methods <em>isVersionAtLeast</em>, <em>setHeaderColor</em>, <em>setBackgroundColor</em>, <em>openLink</em>, <em>openTelegramLink</em>, <em>openInvoice</em> to the class <a href="#initializing-web-apps">WebApp</a>.</li>
<li>Added the field <em>secondary_bg_color</em> to the class <a href="#themeparams">ThemeParams</a>.</li>
<li>Added the method <em>offClick</em> to the class <a href="#mainbutton">MainButton</a>.</li>
<li>Added the fields <em>chat</em>, <em>can_send_after</em> to the class <a href="#webappinitdata">WebAppInitData</a>.</li>
<li>Added the <a href="#events-available-for-web-apps">events</a> <em>backButtonClicked</em>, <em>settingsButtonClicked</em>, <em>invoiceClosed</em>.</li>
</ul>
<hr>
<h3><a class="anchor" name="designing-web-apps" href="#designing-web-apps"><i class="anchor-icon"></i></a>Designing Web Apps</h3>
<h4><a class="anchor" name="color-schemes" href="#color-schemes"><i class="anchor-icon"></i></a>Color Schemes</h4>
<p>Web Apps always receive data about the user&#39;s current <strong>color theme</strong> in real time, so you can adjust the appearance of your interfaces to match it. For example, when users switch between <strong>Day and Night</strong> modes or use various <a href="https://telegram.org/blog/protected-content-delete-by-date-and-more#global-chat-themes-on-android">custom themes</a>.</p>
@ -131,13 +144,14 @@
</blockquote>
<h4><a class="anchor" name="launching-web-apps-from-the-attachment-menu" href="#launching-web-apps-from-the-attachment-menu"><i class="anchor-icon"></i></a>Launching Web Apps from the Attachment Menu</h4>
<blockquote>
<p><strong>TL;DR:</strong> Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from any private chat. To try this mode, open this <a href="https://t.me/durgerkingbot?startattach">attachment menu link</a> for <em>@DurgerKingBot</em>, then use the <img class="icon" src="/file/464001085/2/E4hNXSNQimQ.2503/bf6ffcab3cb3afd43d" alt="Attach"> menu in any <strong>private chat</strong>.</p>
<p><strong>TL;DR:</strong> Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from any chat. To try this mode, open this <a href="https://t.me/durgerkingbot?startattach">attachment menu link</a> for <em>@DurgerKingBot</em>, then use the <img class="icon" src="/file/464001085/2/E4hNXSNQimQ.2503/bf6ffcab3cb3afd43d" alt="Attach"> menu in <strong>any type of chat</strong>.</p>
</blockquote>
<p>Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from <strong>any private chat</strong> (with either a <em>user</em> or <em>another bot</em>).</p>
<p>Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from <strong>any type of chat</strong>. <sup><mark>NEW</mark></sup> You can configure in which types of chats your web app can be started from the attachment menu (private, groups, supergroups or channels).</p>
<p>Attachment menu integration is currently only available for major advertisers on the <a href="https://promote.telegram.org/basics">Telegram Ad Platform</a>. However, <strong>all bots</strong> can use it in the <a href="#using-bots-in-the-test-environment">test server environment</a>.</p>
<p>To enable this feature for your bot, open <a href="https://t.me/botfather">@BotFather</a> <a href="#using-bots-in-the-test-environment">from an account on the test server</a> and send the <code>/setattach</code> command or go to <em>Bot Settings &gt; Configure Attachment Menu</em>. Then specify the URL that will be opened to launch the bot&#39;s Web App via its icon in the attachment menu.</p>
<p>In addition to the user&#39;s <a href="#color-schemes">theme settings</a>, the bot will receive basic user information (<code>ID</code>, <code>name</code>, <code>username</code>, <code>language_code</code>, <code>photo</code>), as well as public info about the chat partner (<code>ID</code>, <code>name</code>, <code>username</code>, <code>photo</code>) and a unique identifier for the web view session <strong>query_id</strong>, which allows messages of any type to be sent to the chat on behalf of the user that opened the bot.</p>
<p>The bot can call the Bot API method <a href="/bots/api#answerwebappquery">answerWebAppQuery</a>, which sends an inline message from the user via the bot to the private chat where it was launched and closes the Web App.</p>
<p><sup><mark>NEW</mark></sup> You can add a &#39;Settings&#39; item to the context menu of your Web App using <a href="https://t.me/botfather">@BotFather</a>. When users select this option from the menu, your bot will receive a <code>settingsButtonClicked</code> event.</p>
<p>In addition to the user&#39;s <a href="#color-schemes">theme settings</a>, the bot will receive basic user information (<code>ID</code>, <code>name</code>, <code>username</code>, <code>language_code</code>, <code>photo</code>), as well as public info about the chat partner (<code>ID</code>, <code>name</code>, <code>username</code>, <code>photo</code>) or the chat info (<code>ID</code>, <code>type</code>, <code>title</code>, <code>username</code>, <code>photo</code>) and a unique identifier for the web view session <strong>query_id</strong>, which allows messages of any type to be sent to the chat on behalf of the user that opened the bot.</p>
<p>The bot can call the Bot API method <a href="/bots/api#answerwebappquery">answerWebAppQuery</a>, which sends an inline message from the user via the bot to the chat where it was launched and closes the Web App.</p>
<blockquote>
<p>You can read more about adding bots to the attachment menu <a href="#adding-bots-to-the-attachment-menu">here</a>.</p>
</blockquote>
@ -166,6 +180,11 @@
<td>An object with input data transferred to the Web App.<br><strong>WARNING:</strong> Data from this field should not be trusted. You should only use data from <em>initData</em> on the bot&#39;s server and only after it has been <a href="#validating-data-received-via-the-web-app">validated</a>.</td>
</tr>
<tr>
<td>version <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td>The version of the Bot API available in the user&#39;s Telegram app.</td>
</tr>
<tr>
<td>colorScheme</td>
<td>String</td>
<td>The color scheme currently used in the Telegram app. Either “light” or “dark”.<br>Also available as the CSS variable <code>var(--tg-color-scheme)</code>.</td>
@ -191,11 +210,46 @@
<td>The height of the visible area of the Web App in its last stable state. Also available in CSS as a variable <code>var(--tg-viewport-stable-height)</code>.<br><br>The application can display just the top part of the Web App, with its lower part remaining outside the screen area. From this position, the user can “pull” the Web App to its maximum height, while the bot can do the same by calling the <strong>expand()</strong> method. Unlike the value of <code>viewportHeight</code>, the value of <code>viewportStableHeight</code> does not change as the position of the Web App changes with user gestures or during animations. The value of <code>viewportStableHeight</code> will be updated after all gestures and animations are completed and the Web App reaches its final size.<br><br><em>Note the <a href="#events-available-for-web-apps">event</a> <code>viewportChanged</code> with the passed parameter <code>isStateStable=true</code>, which will allow you to track when the stable state of the height of the visible area changes.</em></td>
</tr>
<tr>
<td>headerColor <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td>Current header color in the <code>#RRGGBB</code> format.</td>
</tr>
<tr>
<td>backgroundColor <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td>Current background color in the <code>#RRGGBB</code> format.</td>
</tr>
<tr>
<td>BackButton <sup><mark>NEW</mark></sup></td>
<td><a href="#backbutton">BackButton</a></td>
<td>An object for controlling the back button which can be displayed in the header of the Web App in the Telegram interface.</td>
</tr>
<tr>
<td>MainButton</td>
<td><a href="#mainbutton">MainButton</a></td>
<td>An object for controlling the main button, which is displayed at the bottom of the Web App in the Telegram interface.</td>
</tr>
<tr>
<td>HapticFeedback <sup><mark>NEW</mark></sup></td>
<td><a href="#hapticfeedback">HapticFeedback</a></td>
<td>An object for controlling haptic feedback.</td>
</tr>
<tr>
<td>isVersionAtLeast(version) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>Returns true if the user&#39;s app supports a version of the Bot API that is equal to or higher than the version passed as the parameter.</td>
</tr>
<tr>
<td>setHeaderColor(color) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that sets the app header color. You can only pass <em>Telegram.WebApp.themeParams.bg_color</em> or <em>Telegram.WebApp.themeParams.secondary_bg_color</em> as a color or you can use keywords <em>bg_color</em>, <em>secondary_bg_color</em> instead.</td>
</tr>
<tr>
<td>setBackgroundColor(color) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that sets the app background color in the <code>#RRGGBB</code> format or you can use keywords <em>bg_color</em>, <em>secondary_bg_color</em> instead.</td>
</tr>
<tr>
<td>onEvent(eventType, eventHandler)</td>
<td>Function</td>
<td>A method that sets the app event handler. Check <a href="#events-available-for-web-apps">the list of available events</a>.</td>
@ -211,6 +265,21 @@
<td>A method used to send data to the bot. When this method is called, a service message is sent to the bot containing the data <em>data</em> of the length up to 4096 bytes, and the Web App is closed. See the field <em>web_app_data</em> in the class <a href="/bots/api#message">Message</a>.<br><br><em>This method is only available for Web Apps launched via a <a href="#keyboard-button-web-apps">Keyboard button</a>.</em></td>
</tr>
<tr>
<td>openLink(url) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>A method that opens a link in an external browser. The Web App will <em>not</em> be closed.<br><br><em>Note that this method can be called only in response to the user interaction with the Web App interface (e.g. click inside the Web App or on the main button)</em></td>
</tr>
<tr>
<td>openTelegramLink(url) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>A method that opens a telegram link inside Telegram app. The Web App <em>will</em> be closed.</td>
</tr>
<tr>
<td>openInvoice(url[, callback]) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that opens an invoice using the link <em>url</em>. The Web App will receive the <a href="#events-available-for-web-apps">event</a> <em>invoiceClosed</em> when the invoice is closed. If an optional <em>callback</em> parameter was passed, the <em>callback</em> function will be called and the invoice status will be passed as the first argument.</td>
</tr>
<tr>
<td>ready()</td>
<td>Function</td>
<td>A method that informs the Telegram app that the Web App is ready to be displayed.<br>It is recommended to call this method as early as possible, as soon as all essential interface elements are loaded. Once this method is called, the loading placeholder is hidden and the Web App is shown.<br>If the method is not called, the placeholder will be hidden only when the page is fully loaded.</td>
@ -268,12 +337,56 @@
<td>String</td>
<td><em>Optional</em>. Button text color in the <code>#RRGGBB</code> format.<br>Also available as the CSS variable <code>var(--tg-theme-button-text-color)</code>.</td>
</tr>
<tr>
<td>secondary_bg_color <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td><em>Optional</em>. <mark>Bot API 6.1+</mark> Secondary background color in the <code>#RRGGBB</code> format.<br>Also available as the CSS variable <code>var(--tg-theme-secondary-bg-color)</code>.</td>
</tr>
</tbody>
</table>
<div class="blog_image_wrap blog_medium_image_wrap">
<a href="/file/464001058/109a6/XLMi7E5_IvY.218203/90b01ba97b6bc3ab8e" target="_blank"><img src="/file/464001058/109a6/XLMi7E5_IvY.218203/90b01ba97b6bc3ab8e" title="" alt="Color parameters guide" srcset="/file/464001058/109a6/XLMi7E5_IvY.218203/90b01ba97b6bc3ab8e , 2x" /></a>
<div>
<a href="/file/464001695/11185/DAwyUjA7LNA.215601/26f4c8ebf862ae860d" target="_blank"><img src="/file/464001695/11185/DAwyUjA7LNA.215601/26f4c8ebf862ae860d" title="WebViewColors explained" class="dev_page_image" /></a>
</div>
<h4><a class="anchor" name="backbutton" href="#backbutton"><i class="anchor-icon"></i></a>BackButton</h4>
<p><sup><mark>NEW</mark></sup> This object controls the <strong>back</strong> button, which can be displayed in the header of the Web App in the Telegram interface.</p>
<table class="table">
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>isVisible</td>
<td>Boolean</td>
<td>Shows whether the button is visible. Set to <em>false</em> by default.</td>
</tr>
<tr>
<td>onClick(callback)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that sets the button press event handler. An alias for <code>Telegram.WebApp.onEvent(&#39;backButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>offClick(callback)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that removes the button press event handler. An alias for <code>Telegram.WebApp.offEvent(&#39;backButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>show()</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method to make the button active and visible.</td>
</tr>
<tr>
<td>hide()</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method to hide the button.</td>
</tr>
</tbody>
</table>
<p>All these methods return the BackButton object so they can be chained.</p>
<h4><a class="anchor" name="mainbutton" href="#mainbutton"><i class="anchor-icon"></i></a>MainButton</h4>
<p>This object controls the main button, which is displayed at the bottom of the Web App in the Telegram interface.</p>
<table class="table">
@ -326,6 +439,11 @@
<td>A method that sets the button press event handler. An alias for <code>Telegram.WebApp.onEvent(&#39;mainButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>offClick(callback) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>A method that removes the button press event handler. An alias for <code>Telegram.WebApp.offEvent(&#39;mainButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>show()</td>
<td>Function</td>
<td>A method to make the button visible.<br><em>Note that opening the Web App from the <a href="#launching-web-apps-from-the-attachment-menu">attachment menu</a> hides the main button until the user interacts with the Web App interface.</em></td>
@ -363,6 +481,35 @@
</tbody>
</table>
<p>All these methods return the MainButton object so they can be chained.</p>
<h4><a class="anchor" name="hapticfeedback" href="#hapticfeedback"><i class="anchor-icon"></i></a>HapticFeedback</h4>
<p><sup><mark>NEW</mark></sup> This object controls haptic feedback.</p>
<table class="table">
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>impactOccurred(style)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method tells that an impact occurred. The Telegram app may play the appropriate haptics based on style value passed. Style can be one of these values:<br>- <em>light</em>, indicates a collision between small or lightweight UI objects,<br>- <em>medium</em>, indicates a collision between medium-sized or medium-weight UI objects,<br>- <em>heavy</em>, indicates a collision between large or heavyweight UI objects,<br>- <em>rigid</em>, indicates a collision between hard or inflexible UI objects,<br>- <em>soft</em>, indicates a collision between soft or flexible UI objects.</td>
</tr>
<tr>
<td>notificationOccurred(type)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method tells that a task or action has succeeded, failed, or produced a warning. The Telegram app may play the appropriate haptics based on type value passed. Type can be one of these values:<br>- <em>error</em>, indicates that a task or action has failed,<br>- <em>success</em>, indicates that a task or action has completed successfully,<br>- <em>warning</em>, indicates that a task or action produced a warning.</td>
</tr>
<tr>
<td>selectionChanged()</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method tells that the user has changed a selection. The Telegram app may play the appropriate haptics.<br><br><em>Do not use this feedback when the user makes or confirms a selection; use it only when the selection changes.</em></td>
</tr>
</tbody>
</table>
<p>All these methods return the HapticFeedback object so they can be chained.</p>
<h4><a class="anchor" name="webappinitdata" href="#webappinitdata"><i class="anchor-icon"></i></a>WebAppInitData</h4>
<p>This object contains data that is transferred to the Web App when it is opened. It is empty if the Web App was launched from a <a href="#keyboard-button-web-apps">keyboard button</a>.</p>
<table class="table">
@ -387,7 +534,12 @@
<tr>
<td>receiver</td>
<td><a href="#webappuser">WebAppUser</a></td>
<td><em>Optional.</em> An object containing data about the chat partner of the current user in the chat where the bot was launched via the attachment menu. Returned only for Web Apps launched via the attachment menu.</td>
<td><em>Optional.</em> An object containing data about the chat partner of the current user in the chat where the bot was launched via the attachment menu. Returned only for private chats and only for Web Apps launched via the attachment menu.</td>
</tr>
<tr>
<td>chat <sup><mark>NEW</mark></sup></td>
<td><a href="#webappchat">WebAppChat</a></td>
<td><em>Optional.</em> An object containing data about the chat where the bot was launched via the attachment menu. Returned for supergroups, channels and group chats only for Web Apps launched via the attachment menu.</td>
</tr>
<tr>
<td>start_param</td>
@ -395,6 +547,11 @@
<td><em>Optional.</em> The value of the <em>startattach</em> parameter, passed <a href="#adding-bots-to-the-attachment-menu">via link</a>. Only returned for Web Apps when launched from the attachment menu via link.<br><br>The value of the <code>start_param</code> parameter will also be passed in the GET-parameter <code>tgWebAppStartParam</code>, so the Web App can load the correct interface right away.</td>
</tr>
<tr>
<td>can_send_after <sup><mark>NEW</mark></sup></td>
<td>Integer</td>
<td><em>Optional.</em> Time in seconds, after which a message can be sent via the <a href="/bots/api#answerwebappquery">answerWebAppQuery</a> method.</td>
</tr>
<tr>
<td>auth_date</td>
<td>Integer</td>
<td>Unix time when the form was opened.</td>
@ -454,6 +611,44 @@
</tr>
</tbody>
</table>
<h4><a class="anchor" name="webappchat" href="#webappchat"><i class="anchor-icon"></i></a>WebAppChat</h4>
<p><sup><mark>NEW</mark></sup> This object represents a chat.</p>
<table class="table">
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>Integer</td>
<td>Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.</td>
</tr>
<tr>
<td>type</td>
<td>String</td>
<td>Type of chat, can be either “group”, “supergroup” or “channel”</td>
</tr>
<tr>
<td>title</td>
<td>String</td>
<td>Title of the chat</td>
</tr>
<tr>
<td>username</td>
<td>String</td>
<td><em>Optional</em>. Username of the chat</td>
</tr>
<tr>
<td>photo_url</td>
<td>String</td>
<td><em>Optional</em>. URL of the chats photo. The photo can be in .jpeg or .svg formats. Only returned for Web Apps launched from the attachment menu.</td>
</tr>
</tbody>
</table>
<h4><a class="anchor" name="validating-data-received-via-the-web-app" href="#validating-data-received-via-the-web-app"><i class="anchor-icon"></i></a>Validating data received via the Web App</h4>
<p>To validate data received via the Web App, one should send the data from the <em>Telegram.WebApp.initData</em> field to the bot&#39;s backend. The data is a query string, which is composed of a series of field-value pairs.</p>
<p>You can verify the integrity of the data received by comparing the received <em>hash</em> parameter with the hexadecimal representation of the <a href="https://en.wikipedia.org/wiki/Hash-based_message_authentication_code">HMAC-SHA-256</a> signature of the <strong>data-check-string</strong> with the secret key, which is the <a href="https://en.wikipedia.org/wiki/Hash-based_message_authentication_code">HMAC-SHA-256</a> signature of the <a href="/bots#creating-a-new-bot">bot&#39;s token</a> with the constant string <code>WebAppData</code> used as a key.</p>
@ -488,6 +683,18 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
<td><code>mainButtonClicked</code></td>
<td>Occurs when the <a href="#mainbutton">main button</a> is pressed.<br><em>eventHandler</em> receives no parameters.</td>
</tr>
<tr>
<td><code>backButtonClicked</code> <sup><mark>NEW</mark></sup></td>
<td><mark>Bot API 6.1+</mark> Occurrs when the <a href="#backbutton">back button</a> is pressed.<br><em>eventHandler</em> receives no parameters.</td>
</tr>
<tr>
<td><code>settingsButtonClicked</code> <sup><mark>NEW</mark></sup></td>
<td><mark>Bot API 6.1+</mark> Occurrs when the Settings item in context menu is pressed.<br><em>eventHandler</em> receives no parameters.</td>
</tr>
<tr>
<td><code>invoiceClosed</code> <sup><mark>NEW</mark></sup></td>
<td><mark>Bot API 6.1+</mark> Occurrs when the opened invoice is closed.<br><em>eventHandler</em> receives an object with the two fields: <em>url</em> invoice link provided and <em>status</em> one of the invoice statuses:<br>- <strong>paid</strong> invoice was paid successfully,<br>- <strong>cancelled</strong> user closed this invoice without paying,<br>- <strong>failed</strong> user tried to pay, but the payment was failed,<br>- <strong>pending</strong> the payment is still processing. The bot will receive a service message about a <a href="https://core.telegram.org/bots/api#successfulpayment">successful payment</a> when the payment is successfully paid.</td>
</tr>
</tbody>
</table>
<h4><a class="anchor" name="adding-bots-to-the-attachment-menu" href="#adding-bots-to-the-attachment-menu"><i class="anchor-icon"></i></a>Adding Bots to the Attachment Menu</h4>
@ -501,6 +708,9 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
<p>The following link formats are also supported:</p>
<p><code>https://t.me/username?attach=botusername</code><br><code>https://t.me/username?attach=botusername&amp;startattach=command</code><br><code>https://t.me/+1234567890?attach=botusername</code><br><code>https://t.me/+1234567890?attach=botusername&amp;startattach=command</code></p>
<p>These links open the Web App in the attachment menu in the chat with a specific user. If the bot wasn&#39;t already added to the attachment menu, the user will be prompted to do so. If a non-empty <em>startattach</em> parameter was included in the link, it will be passed to the Web App in the <em>start_param</em> field and in the GET parameter <em>tgWebAppStartParam</em>.</p>
<p><mark>Bot API 6.1+</mark> supports a new link format:</p>
<p><code>https://t.me/botusername?startattach&amp;choose=users+bots</code><br><code>https://t.me/botusername?startattach=command&amp;choose=groups+channels</code></p>
<p>Opening such a link prompts the user to choose a specific chat and opens the attachment menu in that chat. If the bot wasn&#39;t already added to the attachment menu, the user will be prompted to do so. You can specify which types of chats the user will be able to choose from. It can be one or more of the following types: <em>users</em>, <em>bots</em>, <em>groups</em>, <em>channels</em> separated by a <code>+</code> sign. If a non-empty <em>startattach</em> parameter was included in the link, it will be passed to the Web App in the <em>start_param</em> field and in the GET parameter <em>tgWebAppStartParam</em>.</p>
<h3><a class="anchor" name="testing-web-apps" href="#testing-web-apps"><i class="anchor-icon"></i></a>Testing Web Apps</h3>
<h4><a class="anchor" name="using-bots-in-the-test-environment" href="#using-bots-in-the-test-environment"><i class="anchor-icon"></i></a>Using bots in the test environment</h4>
<p>To log in to the test environment, use either of the following:</p>
@ -511,10 +721,31 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
</ul>
<p>The test environment is completely separate from the main environment, so you will need to create a <strong>new user account</strong> and a <strong>new bot</strong> with @BotFather.</p>
<p>After receiving your bot token, you can send requests to the Bot API in this format: </p>
<p><code>https://api.telegram.org/bot&lt;token&gt;/test/METHOD_NAME</code></p>
<pre><code>https://api.telegram.org/bot&lt;token&gt;/test/METHOD_NAME</code></pre>
<blockquote>
<p><strong>Note:</strong> When working with the test environment, you may use HTTP links without TLS to test your Web App.</p>
</blockquote>
<h4><a class="anchor" name="debug-mode-for-web-apps" href="#debug-mode-for-web-apps"><i class="anchor-icon"></i></a>Debug Mode for Web Apps</h4>
<p>Use these tools to find app-specific issues in your Web App:</p>
<p><strong>Android</strong></p>
<ul>
<li><a href="https://developer.chrome.com/docs/devtools/remote-debugging/">Enable USB-Debugging</a> on your device.</li>
<li>In Telegram Settings, scroll all the way down, press and hold on the <strong>version number</strong> two times.</li>
<li>Choose <em>Enable WebView Debug</em> in the Debug Settings.</li>
<li>Connect your phone to your computer and open <code>chrome://inspect/#devices</code> in Chrome you will see your Web App there when you launch it on your phone.</li>
</ul>
<p><strong>Telegram Desktop on Windows and Linux</strong></p>
<ul>
<li>Download and launch the <a href="https://desktop.telegram.org/changelog#beta-version">Beta Version</a> of Telegram Desktop on <strong>Windows</strong> or <strong>Linux</strong> (not supported on Telegram Desktop for macOS yet).</li>
<li>Go to <em>Settings &gt; Advanced &gt; Experimental settings &gt; Enable webview inspection</em>.</li>
<li>Right click in the WebView and choose <em>Inspect</em>.</li>
</ul>
<p><strong>Telegram macOS</strong></p>
<ul>
<li>Download and launch the <a href="https://telegram.org/dl/macos/beta">Beta Version</a> of Telegram macOS.</li>
<li>Quickly click 5 times on the Settings icon to open the debug menu and enable “Debug Web Apps”.</li>
<li>Right click in the web app and choose <em>Inspect Element</em>.</li>
</ul>
</div>
</div>

View file

@ -54,6 +54,43 @@ To learn how to create…">
<blockquote>
<p>Subscribe to <a href="https://t.me/botnews">@BotNews</a> to be the first to know about the latest updates and join the discussion in <a href="https://t.me/bottalk">@BotTalk</a></p>
</blockquote>
<h3><a class="anchor" name="june-20-2022" href="#june-20-2022"><i class="anchor-icon"></i></a>June 20, 2022</h3>
<p><strong>Bot API 6.1</strong></p>
<p><strong>Media in Descriptions</strong></p>
<ul>
<li>Added support for photos and videos in the &#39;What can this bot do?&#39; section (shown on the bot&#39;s start screen). Use <a href="https://t.me/BotFather">BotFather</a> to set up media.</li>
</ul>
<p><strong>Web App Improvements</strong></p>
<ul>
<li>Added the fields <em>version</em>, <em>headerColor</em>, <em>backgroundColor</em>, <em>BackButton</em>, <em>HapticFeedback</em> and the methods <em>isVersionAtLeast</em>, <em>setHeaderColor</em>, <em>setBackgroundColor</em>, <em>openLink</em>, <em>openTelegramLink</em>, <em>openInvoice</em> to the class <a href="/bots/webapps#initializing-web-apps">WebApp</a>.</li>
<li>Added the field <em>secondary_bg_color</em> to the class <a href="/bots/webapps#themeparams">ThemeParams</a>.</li>
<li>Added the method <em>offClick</em> to the class <a href="/bots/webapps#mainbutton">MainButton</a>.</li>
<li>Added the fields <em>chat</em>, <em>can_send_after</em> to the class <a href="/bots/webapps#webappinitdata">WebAppInitData</a>.</li>
<li>Added the events <em>backButtonClicked</em>, <em>settingsButtonClicked</em>, <em>invoiceClosed</em>.</li>
</ul>
<p><strong>Join Requests &amp; Payments</strong></p>
<ul>
<li>Added the fields <em>join_to_send_messages</em> and <em>join_by_request</em> to the class <a href="/bots/api#chat">Chat</a>.</li>
<li>Added the ability to process join requests which were created <a href="https://telegram.org/blog/700-million-and-premium#join-requests-for-public-groups">without an invite link</a>. Bots will receive a “chat_join_request” update as usual.</li>
<li>Added the method <a href="/bots/api#createinvoicelink">createInvoiceLink</a> to generate an HTTP link for an invoice.</li>
</ul>
<p><strong>Telegram Premium Support</strong> (<a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">more info</a>)</p>
<ul>
<li>The maximum value of the field <em>file_size</em> in the classes <a href="/bots/api#animation">Animation</a>, <a href="/bots/api#audio">Audio</a>, <a href="/bots/api#document">Document</a>, <a href="/bots/api#video">Video</a>, <a href="/bots/api#voice">Voice</a>, and <a href="/bots/api#file">File</a> can no longer be stored in a signed 32-bit integer type. This change is necessary to support 4GB files uploaded by <a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">premium accounts</a>.</li>
<li>Added the field <em>is_premium</em> to the class <a href="/bots/api#user">User</a>.</li>
<li>Added the field <em>premium_animation</em> to the class <a href="/bots/api#sticker">Sticker</a>.</li>
</ul>
<p><strong>Attachment Menu Integration</strong></p>
<ul>
<li>Added the field <em>added_to_attachment_menu</em> to the class <a href="/bots/api#user">User</a>.</li>
<li>Bots integrated in the attachment menu can now be used in groups, supergroups and channels.</li>
<li>Added support for t.me links that can be used to select the chat in which the attachment menu with the bot will be opened.</li>
</ul>
<p><strong>Other Changes</strong></p>
<ul>
<li>Added the parameter <em>secret_token</em> to the method <a href="/bots/api#setwebhook">setWebhook</a>.</li>
<li>As previously announced, only HTTPS links are now allowed in <em>login_url</em> inline keyboard buttons.</li>
</ul>
<h3><a class="anchor" name="april-16-2022" href="#april-16-2022"><i class="anchor-icon"></i></a>April 16, 2022</h3>
<p><strong>Bot API 6.0</strong></p>
<ul>

View file

@ -53,6 +53,43 @@ To learn how to create…">
<blockquote>
<p>Subscribe to <a href="https://t.me/botnews">@BotNews</a> to be the first to know about the latest updates and join the discussion in <a href="https://t.me/bottalk">@BotTalk</a></p>
</blockquote>
<h4><a class="anchor" name="june-20-2022" href="#june-20-2022"><i class="anchor-icon"></i></a>June 20, 2022</h4>
<p><strong>Bot API 6.1</strong></p>
<p><strong>Media in Descriptions</strong></p>
<ul>
<li>Added support for photos and videos in the &#39;What can this bot do?&#39; section (shown on the bot&#39;s start screen). Use <a href="https://t.me/BotFather">BotFather</a> to set up media.</li>
</ul>
<p><strong>Web App Improvements</strong></p>
<ul>
<li>Added the fields <em>version</em>, <em>headerColor</em>, <em>backgroundColor</em>, <em>BackButton</em>, <em>HapticFeedback</em> and the methods <em>isVersionAtLeast</em>, <em>setHeaderColor</em>, <em>setBackgroundColor</em>, <em>openLink</em>, <em>openTelegramLink</em>, <em>openInvoice</em> to the class <a href="/bots/webapps#initializing-web-apps">WebApp</a>.</li>
<li>Added the field <em>secondary_bg_color</em> to the class <a href="/bots/webapps#themeparams">ThemeParams</a>.</li>
<li>Added the method <em>offClick</em> to the class <a href="/bots/webapps#mainbutton">MainButton</a>.</li>
<li>Added the fields <em>chat</em>, <em>can_send_after</em> to the class <a href="/bots/webapps#webappinitdata">WebAppInitData</a>.</li>
<li>Added the events <em>backButtonClicked</em>, <em>settingsButtonClicked</em>, <em>invoiceClosed</em>.</li>
</ul>
<p><strong>Join Requests &amp; Payments</strong></p>
<ul>
<li>Added the fields <em>join_to_send_messages</em> and <em>join_by_request</em> to the class <a href="#chat">Chat</a>.</li>
<li>Added the ability to process join requests which were created <a href="https://telegram.org/blog/700-million-and-premium#join-requests-for-public-groups">without an invite link</a>. Bots will receive a “chat_join_request” update as usual.</li>
<li>Added the method <a href="#createinvoicelink">createInvoiceLink</a> to generate an HTTP link for an invoice.</li>
</ul>
<p><strong>Telegram Premium Support</strong> (<a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">more info</a>)</p>
<ul>
<li>The maximum value of the field <em>file_size</em> in the classes <a href="#animation">Animation</a>, <a href="#audio">Audio</a>, <a href="#document">Document</a>, <a href="#video">Video</a>, <a href="#voice">Voice</a>, and <a href="#file">File</a> can no longer be stored in a signed 32-bit integer type. This change is necessary to support 4GB files uploaded by <a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">premium accounts</a>.</li>
<li>Added the field <em>is_premium</em> to the class <a href="#user">User</a>.</li>
<li>Added the field <em>premium_animation</em> to the class <a href="#sticker">Sticker</a>.</li>
</ul>
<p><strong>Attachment Menu Integration</strong></p>
<ul>
<li>Added the field <em>added_to_attachment_menu</em> to the class <a href="#user">User</a>.</li>
<li>Bots integrated in the attachment menu can now be used in groups, supergroups and channels.</li>
<li>Added support for t.me links that can be used to select the chat in which the attachment menu with the bot will be opened.</li>
</ul>
<p><strong>Other Changes</strong></p>
<ul>
<li>Added the parameter <em>secret_token</em> to the method <a href="#setwebhook">setWebhook</a>.</li>
<li>As previously announced, only HTTPS links are now allowed in <em>login_url</em> inline keyboard buttons.</li>
</ul>
<h4><a class="anchor" name="april-16-2022" href="#april-16-2022"><i class="anchor-icon"></i></a>April 16, 2022</h4>
<p><strong>Bot API 6.0</strong></p>
<ul>
@ -89,19 +126,6 @@ To learn how to create…">
<li>Added new <a href="#messageentity">MessageEntity</a> type “spoiler”.</li>
<li>Added the ability to specify spoiler entities using <a href="#html-style">HTML</a> and <a href="#markdownv2-style">MarkdownV2</a> formatting options.</li>
</ul>
<h4><a class="anchor" name="december-7-2021" href="#december-7-2021"><i class="anchor-icon"></i></a>December 7, 2021</h4>
<p><strong>Bot API 5.5</strong></p>
<ul>
<li>Bots are now allowed to contact users who sent a join request to a chat where the bot is an administrator with the <em>can_invite_users</em> administrator right even if the user never interacted with the bot before.</li>
<li>Added support for mentioning users by their ID in inline keyboards. This will only work in Telegram versions released after December 7, 2021. Older clients will display <em>unsupported message</em>.</li>
<li>Added the methods <a href="#banchatsenderchat">banChatSenderChat</a> and <a href="#unbanchatsenderchat">unbanChatSenderChat</a> for banning and unbanning channel chats in supergroups and channels.</li>
<li>Added the field <em>has_private_forwards</em> to the class <a href="#chat">Chat</a> for private chats, which can be used to check the possibility of mentioning the user by their ID.</li>
<li>Added the field <em>has_protected_content</em> to the classes <a href="#chat">Chat</a> and <a href="#message">Message</a>.</li>
<li>Added the field <em>is_automatic_forward</em> to the class <a href="#message">Message</a>.</li>
</ul>
<p><strong>Note:</strong> After this update it will become impossible to forward messages from some chats. Use the fields <em>has_protected_content</em> in the classes <a href="#message">Message</a> and <a href="#chat">Chat</a> to check this.</p>
<p><strong>Note:</strong> After this update users are able to send messages on behalf of channels they own. Bots are expected to use the field <em>sender_chat</em> in the class <a href="#message">Message</a> to correctly support such messages.</p>
<p><strong>Note:</strong> As previously announced, user identifiers can now have up to 52 significant bits and require a 64-bit integer or double-precision float type to be stored safely.</p>
<p><strong><a href="/bots/api-changelog">See earlier changes »</a></strong></p>
<h3><a class="anchor" name="authorizing-your-bot" href="#authorizing-your-bot"><i class="anchor-icon"></i></a>Authorizing your bot</h3>
<p>Each bot is given a unique authentication token <a href="/bots#6-botfather">when it is created</a>. The token looks something like <code>123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11</code>, but we&#39;ll use simply <strong>&lt;token&gt;</strong> in this document instead. You can learn about obtaining tokens and generating new ones in <a href="https://core.telegram.org/bots#6-botfather">this document</a>.</p>
@ -273,7 +297,7 @@ To learn how to create…">
</blockquote>
<h4><a class="anchor" name="setwebhook" href="#setwebhook"><i class="anchor-icon"></i></a>setWebhook</h4>
<p>Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized <a href="#update">Update</a>. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns <em>True</em> on success.</p>
<p>If you&#39;d like to make sure that the webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. <code>https://www.example.com/&lt;token&gt;</code>. Since nobody else knows your bot&#39;s token, you can be pretty sure it&#39;s us.</p>
<p>If you&#39;d like to make sure that the webhook was set by you, you can specify secret data in the parameter <em>secret_token</em>. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.</p>
<table class="table">
<thead>
<tr>
@ -320,11 +344,17 @@ To learn how to create…">
<td>Optional</td>
<td>Pass <em>True</em> to drop all pending updates</td>
</tr>
<tr>
<td>secret_token</td>
<td>String</td>
<td>Optional</td>
<td>A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters <code>A-Z</code>, <code>a-z</code>, <code>0-9</code>, <code>_</code> and <code>-</code> are allowed. The header is useful to ensure that the request comes from a webhook set by you.</td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>Notes</strong><br><strong>1.</strong> You will not be able to receive updates using <a href="#getupdates">getUpdates</a> for as long as an outgoing webhook is set up.<br><strong>2.</strong> To use a self-signed certificate, you need to upload your <a href="/bots/self-signed">public key certificate</a> using <em>certificate</em> parameter. Please upload as InputFile, sending a String will not work.<br><strong>3.</strong> Ports currently supported <em>for webhooks</em>: <strong>443, 80, 88, 8443</strong>.</p>
<p><strong>NEW!</strong> If you&#39;re having any trouble setting up webhooks, please check out this <a href="/bots/webhooks">amazing guide to webhooks</a>.</p>
<p>If you&#39;re having any trouble setting up webhooks, please check out this <a href="/bots/webhooks">amazing guide to webhooks</a>.</p>
</blockquote>
<h4><a class="anchor" name="deletewebhook" href="#deletewebhook"><i class="anchor-icon"></i></a>deleteWebhook</h4>
<p>Use this method to remove webhook integration if you decide to switch back to <a href="#getupdates">getUpdates</a>. Returns <em>True</em> on success.</p>
@ -454,6 +484,16 @@ To learn how to create…">
<td><em>Optional</em>. <a href="https://en.wikipedia.org/wiki/IETF_language_tag">IETF language tag</a> of the user&#39;s language</td>
</tr>
<tr>
<td>is_premium</td>
<td>True</td>
<td><em>Optional</em>. <em>True</em>, if this user is a Telegram Premium user</td>
</tr>
<tr>
<td>added_to_attachment_menu</td>
<td>True</td>
<td><em>Optional</em>. <em>True</em>, if this user added the bot to the attachment menu</td>
</tr>
<tr>
<td>can_join_groups</td>
<td>Boolean</td>
<td><em>Optional</em>. <em>True</em>, if the bot can be invited to groups. Returned only in <a href="#getme">getMe</a>.</td>
@ -527,6 +567,16 @@ To learn how to create…">
<td><em>Optional</em>. <em>True</em>, if privacy settings of the other party in the private chat allows to use <code>tg://user?id=&lt;user_id&gt;</code> links only in chats with the user. Returned only in <a href="#getchat">getChat</a>.</td>
</tr>
<tr>
<td>join_to_send_messages</td>
<td>True</td>
<td><em>Optional</em>. <em>True</em>, if users need to join the supergroup before they can send messages. Returned only in <a href="#getchat">getChat</a>.</td>
</tr>
<tr>
<td>join_by_request</td>
<td>True</td>
<td><em>Optional</em>. <em>True</em>, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in <a href="#getchat">getChat</a>.</td>
</tr>
<tr>
<td>description</td>
<td>String</td>
<td><em>Optional</em>. Description, for groups, supergroups and channel chats. Returned only in <a href="#getchat">getChat</a>.</td>
@ -687,7 +737,7 @@ To learn how to create…">
<tr>
<td>text</td>
<td>String</td>
<td><em>Optional</em>. For text messages, the actual UTF-8 text of the message, 0-4096 characters</td>
<td><em>Optional</em>. For text messages, the actual UTF-8 text of the message</td>
</tr>
<tr>
<td>entities</td>
@ -737,7 +787,7 @@ To learn how to create…">
<tr>
<td>caption</td>
<td>String</td>
<td><em>Optional</em>. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters</td>
<td><em>Optional</em>. Caption for the animation, audio, document, photo, video or voice</td>
</tr>
<tr>
<td>caption_entities</td>
@ -1942,7 +1992,7 @@ To learn how to create…">
<tr>
<td>login_url</td>
<td><a href="#loginurl">LoginUrl</a></td>
<td><em>Optional</em>. An HTTP URL used to automatically authorize the user. Can be used as a replacement for the <a href="https://core.telegram.org/widgets/login">Telegram Login Widget</a>.</td>
<td><em>Optional</em>. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the <a href="https://core.telegram.org/widgets/login">Telegram Login Widget</a>.</td>
</tr>
<tr>
<td>switch_inline_query</td>
@ -6241,6 +6291,11 @@ pre-formatted fixed-width code block written in the Python programming language
<td><em>Optional</em>. Name of the sticker set to which the sticker belongs</td>
</tr>
<tr>
<td>premium_animation</td>
<td><a href="#file">File</a></td>
<td><em>Optional</em>. Premium animation for the sticker, if the sticker is premium</td>
</tr>
<tr>
<td>mask_position</td>
<td><a href="#maskposition">MaskPosition</a></td>
<td><em>Optional</em>. For mask stickers, the position where the mask should be placed</td>
@ -8663,6 +8718,140 @@ pre-formatted fixed-width code block written in the Python programming language
</tr>
</tbody>
</table>
<h4><a class="anchor" name="createinvoicelink" href="#createinvoicelink"><i class="anchor-icon"></i></a>createInvoiceLink</h4>
<p>Use this method to create a link for an invoice. Returns the created invoice link as <em>String</em> on success.</p>
<table class="table">
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>title</td>
<td>String</td>
<td>Yes</td>
<td>Product name, 1-32 characters</td>
</tr>
<tr>
<td>description</td>
<td>String</td>
<td>Yes</td>
<td>Product description, 1-255 characters</td>
</tr>
<tr>
<td>payload</td>
<td>String</td>
<td>Yes</td>
<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>
</tr>
<tr>
<td>provider_token</td>
<td>String</td>
<td>Yes</td>
<td>Payment provider token, obtained via <a href="https://t.me/botfather">BotFather</a></td>
</tr>
<tr>
<td>currency</td>
<td>String</td>
<td>Yes</td>
<td>Three-letter ISO 4217 currency code, see <a href="/bots/payments#supported-currencies">more on currencies</a></td>
</tr>
<tr>
<td>prices</td>
<td>Array of <a href="#labeledprice">LabeledPrice</a></td>
<td>Yes</td>
<td>Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)</td>
</tr>
<tr>
<td>max_tip_amount</td>
<td>Integer</td>
<td>Optional</td>
<td>The maximum accepted amount for tips in the <em>smallest units</em> of the currency (integer, <strong>not</strong> float/double). For example, for a maximum tip of <code>US$ 1.45</code> pass <code>max_tip_amount = 145</code>. See the <em>exp</em> parameter in <a href="https://core.telegram.org/bots/payments/currencies.json">currencies.json</a>, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0</td>
</tr>
<tr>
<td>suggested_tip_amounts</td>
<td>Array of Integer</td>
<td>Optional</td>
<td>A JSON-serialized array of suggested amounts of tips in the <em>smallest units</em> of the currency (integer, <strong>not</strong> float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed <em>max_tip_amount</em>.</td>
</tr>
<tr>
<td>provider_data</td>
<td>String</td>
<td>Optional</td>
<td>JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.</td>
</tr>
<tr>
<td>photo_url</td>
<td>String</td>
<td>Optional</td>
<td>URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.</td>
</tr>
<tr>
<td>photo_size</td>
<td>Integer</td>
<td>Optional</td>
<td>Photo size in bytes</td>
</tr>
<tr>
<td>photo_width</td>
<td>Integer</td>
<td>Optional</td>
<td>Photo width</td>
</tr>
<tr>
<td>photo_height</td>
<td>Integer</td>
<td>Optional</td>
<td>Photo height</td>
</tr>
<tr>
<td>need_name</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if you require the user&#39;s full name to complete the order</td>
</tr>
<tr>
<td>need_phone_number</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if you require the user&#39;s phone number to complete the order</td>
</tr>
<tr>
<td>need_email</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if you require the user&#39;s email address to complete the order</td>
</tr>
<tr>
<td>need_shipping_address</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if you require the user&#39;s shipping address to complete the order</td>
</tr>
<tr>
<td>send_phone_number_to_provider</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if the user&#39;s phone number should be sent to the provider</td>
</tr>
<tr>
<td>send_email_to_provider</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if the user&#39;s email address should be sent to the provider</td>
</tr>
<tr>
<td>is_flexible</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if the final price depends on the shipping method</td>
</tr>
</tbody>
</table>
<h4><a class="anchor" name="answershippingquery" href="#answershippingquery"><i class="anchor-icon"></i></a>answerShippingQuery</h4>
<p>If you sent an invoice requesting a shipping address and the parameter <em>is_flexible</em> was specified, the Bot API will send an <a href="#update">Update</a> with a <em>shipping_query</em> field to the bot. Use this method to reply to shipping queries. On success, <em>True</em> is returned.</p>
<table class="table">

View file

@ -56,6 +56,19 @@
<p>To see a <strong>Web App</strong> in action, try our sample <a href="https://t.me/durgerkingbot">@DurgerKingBot</a>.</p>
</blockquote>
<hr>
<h3><a class="anchor" name="recent-changes" href="#recent-changes"><i class="anchor-icon"></i></a>Recent changes</h3>
<h4><a class="anchor" name="june-20-2022" href="#june-20-2022"><i class="anchor-icon"></i></a>June 20, 2022</h4>
<p><strong>Bot API 6.1</strong></p>
<ul>
<li>Added the ability to use bots added to the attachment menu in group, supergroup and channel chats.</li>
<li>Added support for <a href="#adding-bots-to-the-attachment-menu">t.me links</a> that can be used to select the chat in which the attachment menu with the bot will be opened.</li>
<li>Added the fields <em>version</em>, <em>headerColor</em>, <em>backgroundColor</em>, <em>BackButton</em>, <em>HapticFeedback</em> and the methods <em>isVersionAtLeast</em>, <em>setHeaderColor</em>, <em>setBackgroundColor</em>, <em>openLink</em>, <em>openTelegramLink</em>, <em>openInvoice</em> to the class <a href="#initializing-web-apps">WebApp</a>.</li>
<li>Added the field <em>secondary_bg_color</em> to the class <a href="#themeparams">ThemeParams</a>.</li>
<li>Added the method <em>offClick</em> to the class <a href="#mainbutton">MainButton</a>.</li>
<li>Added the fields <em>chat</em>, <em>can_send_after</em> to the class <a href="#webappinitdata">WebAppInitData</a>.</li>
<li>Added the <a href="#events-available-for-web-apps">events</a> <em>backButtonClicked</em>, <em>settingsButtonClicked</em>, <em>invoiceClosed</em>.</li>
</ul>
<hr>
<h3><a class="anchor" name="designing-web-apps" href="#designing-web-apps"><i class="anchor-icon"></i></a>Designing Web Apps</h3>
<h4><a class="anchor" name="color-schemes" href="#color-schemes"><i class="anchor-icon"></i></a>Color Schemes</h4>
<p>Web Apps always receive data about the user&#39;s current <strong>color theme</strong> in real time, so you can adjust the appearance of your interfaces to match it. For example, when users switch between <strong>Day and Night</strong> modes or use various <a href="https://telegram.org/blog/protected-content-delete-by-date-and-more#global-chat-themes-on-android">custom themes</a>.</p>
@ -131,13 +144,14 @@
</blockquote>
<h4><a class="anchor" name="launching-web-apps-from-the-attachment-menu" href="#launching-web-apps-from-the-attachment-menu"><i class="anchor-icon"></i></a>Launching Web Apps from the Attachment Menu</h4>
<blockquote>
<p><strong>TL;DR:</strong> Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from any private chat. To try this mode, open this <a href="https://t.me/durgerkingbot?startattach">attachment menu link</a> for <em>@DurgerKingBot</em>, then use the <img class="icon" src="/file/464001085/2/E4hNXSNQimQ.2503/bf6ffcab3cb3afd43d" alt="Attach"> menu in any <strong>private chat</strong>.</p>
<p><strong>TL;DR:</strong> Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from any chat. To try this mode, open this <a href="https://t.me/durgerkingbot?startattach">attachment menu link</a> for <em>@DurgerKingBot</em>, then use the <img class="icon" src="/file/464001085/2/E4hNXSNQimQ.2503/bf6ffcab3cb3afd43d" alt="Attach"> menu in <strong>any type of chat</strong>.</p>
</blockquote>
<p>Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from <strong>any private chat</strong> (with either a <em>user</em> or <em>another bot</em>).</p>
<p>Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from <strong>any type of chat</strong>. <sup><mark>NEW</mark></sup> You can configure in which types of chats your web app can be started from the attachment menu (private, groups, supergroups or channels).</p>
<p>Attachment menu integration is currently only available for major advertisers on the <a href="https://promote.telegram.org/basics">Telegram Ad Platform</a>. However, <strong>all bots</strong> can use it in the <a href="#using-bots-in-the-test-environment">test server environment</a>.</p>
<p>To enable this feature for your bot, open <a href="https://t.me/botfather">@BotFather</a> <a href="#using-bots-in-the-test-environment">from an account on the test server</a> and send the <code>/setattach</code> command or go to <em>Bot Settings &gt; Configure Attachment Menu</em>. Then specify the URL that will be opened to launch the bot&#39;s Web App via its icon in the attachment menu.</p>
<p>In addition to the user&#39;s <a href="#color-schemes">theme settings</a>, the bot will receive basic user information (<code>ID</code>, <code>name</code>, <code>username</code>, <code>language_code</code>, <code>photo</code>), as well as public info about the chat partner (<code>ID</code>, <code>name</code>, <code>username</code>, <code>photo</code>) and a unique identifier for the web view session <strong>query_id</strong>, which allows messages of any type to be sent to the chat on behalf of the user that opened the bot.</p>
<p>The bot can call the Bot API method <a href="/bots/api#answerwebappquery">answerWebAppQuery</a>, which sends an inline message from the user via the bot to the private chat where it was launched and closes the Web App.</p>
<p><sup><mark>NEW</mark></sup> You can add a &#39;Settings&#39; item to the context menu of your Web App using <a href="https://t.me/botfather">@BotFather</a>. When users select this option from the menu, your bot will receive a <code>settingsButtonClicked</code> event.</p>
<p>In addition to the user&#39;s <a href="#color-schemes">theme settings</a>, the bot will receive basic user information (<code>ID</code>, <code>name</code>, <code>username</code>, <code>language_code</code>, <code>photo</code>), as well as public info about the chat partner (<code>ID</code>, <code>name</code>, <code>username</code>, <code>photo</code>) or the chat info (<code>ID</code>, <code>type</code>, <code>title</code>, <code>username</code>, <code>photo</code>) and a unique identifier for the web view session <strong>query_id</strong>, which allows messages of any type to be sent to the chat on behalf of the user that opened the bot.</p>
<p>The bot can call the Bot API method <a href="/bots/api#answerwebappquery">answerWebAppQuery</a>, which sends an inline message from the user via the bot to the chat where it was launched and closes the Web App.</p>
<blockquote>
<p>You can read more about adding bots to the attachment menu <a href="#adding-bots-to-the-attachment-menu">here</a>.</p>
</blockquote>
@ -166,6 +180,11 @@
<td>An object with input data transferred to the Web App.<br><strong>WARNING:</strong> Data from this field should not be trusted. You should only use data from <em>initData</em> on the bot&#39;s server and only after it has been <a href="#validating-data-received-via-the-web-app">validated</a>.</td>
</tr>
<tr>
<td>version <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td>The version of the Bot API available in the user&#39;s Telegram app.</td>
</tr>
<tr>
<td>colorScheme</td>
<td>String</td>
<td>The color scheme currently used in the Telegram app. Either “light” or “dark”.<br>Also available as the CSS variable <code>var(--tg-color-scheme)</code>.</td>
@ -191,11 +210,46 @@
<td>The height of the visible area of the Web App in its last stable state. Also available in CSS as a variable <code>var(--tg-viewport-stable-height)</code>.<br><br>The application can display just the top part of the Web App, with its lower part remaining outside the screen area. From this position, the user can “pull” the Web App to its maximum height, while the bot can do the same by calling the <strong>expand()</strong> method. Unlike the value of <code>viewportHeight</code>, the value of <code>viewportStableHeight</code> does not change as the position of the Web App changes with user gestures or during animations. The value of <code>viewportStableHeight</code> will be updated after all gestures and animations are completed and the Web App reaches its final size.<br><br><em>Note the <a href="#events-available-for-web-apps">event</a> <code>viewportChanged</code> with the passed parameter <code>isStateStable=true</code>, which will allow you to track when the stable state of the height of the visible area changes.</em></td>
</tr>
<tr>
<td>headerColor <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td>Current header color in the <code>#RRGGBB</code> format.</td>
</tr>
<tr>
<td>backgroundColor <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td>Current background color in the <code>#RRGGBB</code> format.</td>
</tr>
<tr>
<td>BackButton <sup><mark>NEW</mark></sup></td>
<td><a href="#backbutton">BackButton</a></td>
<td>An object for controlling the back button which can be displayed in the header of the Web App in the Telegram interface.</td>
</tr>
<tr>
<td>MainButton</td>
<td><a href="#mainbutton">MainButton</a></td>
<td>An object for controlling the main button, which is displayed at the bottom of the Web App in the Telegram interface.</td>
</tr>
<tr>
<td>HapticFeedback <sup><mark>NEW</mark></sup></td>
<td><a href="#hapticfeedback">HapticFeedback</a></td>
<td>An object for controlling haptic feedback.</td>
</tr>
<tr>
<td>isVersionAtLeast(version) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>Returns true if the user&#39;s app supports a version of the Bot API that is equal to or higher than the version passed as the parameter.</td>
</tr>
<tr>
<td>setHeaderColor(color) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that sets the app header color. You can only pass <em>Telegram.WebApp.themeParams.bg_color</em> or <em>Telegram.WebApp.themeParams.secondary_bg_color</em> as a color or you can use keywords <em>bg_color</em>, <em>secondary_bg_color</em> instead.</td>
</tr>
<tr>
<td>setBackgroundColor(color) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that sets the app background color in the <code>#RRGGBB</code> format or you can use keywords <em>bg_color</em>, <em>secondary_bg_color</em> instead.</td>
</tr>
<tr>
<td>onEvent(eventType, eventHandler)</td>
<td>Function</td>
<td>A method that sets the app event handler. Check <a href="#events-available-for-web-apps">the list of available events</a>.</td>
@ -211,6 +265,21 @@
<td>A method used to send data to the bot. When this method is called, a service message is sent to the bot containing the data <em>data</em> of the length up to 4096 bytes, and the Web App is closed. See the field <em>web_app_data</em> in the class <a href="/bots/api#message">Message</a>.<br><br><em>This method is only available for Web Apps launched via a <a href="#keyboard-button-web-apps">Keyboard button</a>.</em></td>
</tr>
<tr>
<td>openLink(url) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>A method that opens a link in an external browser. The Web App will <em>not</em> be closed.<br><br><em>Note that this method can be called only in response to the user interaction with the Web App interface (e.g. click inside the Web App or on the main button)</em></td>
</tr>
<tr>
<td>openTelegramLink(url) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>A method that opens a telegram link inside Telegram app. The Web App <em>will</em> be closed.</td>
</tr>
<tr>
<td>openInvoice(url[, callback]) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that opens an invoice using the link <em>url</em>. The Web App will receive the <a href="#events-available-for-web-apps">event</a> <em>invoiceClosed</em> when the invoice is closed. If an optional <em>callback</em> parameter was passed, the <em>callback</em> function will be called and the invoice status will be passed as the first argument.</td>
</tr>
<tr>
<td>ready()</td>
<td>Function</td>
<td>A method that informs the Telegram app that the Web App is ready to be displayed.<br>It is recommended to call this method as early as possible, as soon as all essential interface elements are loaded. Once this method is called, the loading placeholder is hidden and the Web App is shown.<br>If the method is not called, the placeholder will be hidden only when the page is fully loaded.</td>
@ -268,12 +337,56 @@
<td>String</td>
<td><em>Optional</em>. Button text color in the <code>#RRGGBB</code> format.<br>Also available as the CSS variable <code>var(--tg-theme-button-text-color)</code>.</td>
</tr>
<tr>
<td>secondary_bg_color <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td><em>Optional</em>. <mark>Bot API 6.1+</mark> Secondary background color in the <code>#RRGGBB</code> format.<br>Also available as the CSS variable <code>var(--tg-theme-secondary-bg-color)</code>.</td>
</tr>
</tbody>
</table>
<div class="blog_image_wrap blog_medium_image_wrap">
<a href="/file/464001058/109a6/XLMi7E5_IvY.218203/90b01ba97b6bc3ab8e" target="_blank"><img src="/file/464001058/109a6/XLMi7E5_IvY.218203/90b01ba97b6bc3ab8e" title="" alt="Color parameters guide" srcset="/file/464001058/109a6/XLMi7E5_IvY.218203/90b01ba97b6bc3ab8e , 2x" /></a>
<div>
<a href="/file/464001695/11185/DAwyUjA7LNA.215601/26f4c8ebf862ae860d" target="_blank"><img src="/file/464001695/11185/DAwyUjA7LNA.215601/26f4c8ebf862ae860d" title="WebViewColors explained" class="dev_page_image" /></a>
</div>
<h4><a class="anchor" name="backbutton" href="#backbutton"><i class="anchor-icon"></i></a>BackButton</h4>
<p><sup><mark>NEW</mark></sup> This object controls the <strong>back</strong> button, which can be displayed in the header of the Web App in the Telegram interface.</p>
<table class="table">
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>isVisible</td>
<td>Boolean</td>
<td>Shows whether the button is visible. Set to <em>false</em> by default.</td>
</tr>
<tr>
<td>onClick(callback)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that sets the button press event handler. An alias for <code>Telegram.WebApp.onEvent(&#39;backButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>offClick(callback)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that removes the button press event handler. An alias for <code>Telegram.WebApp.offEvent(&#39;backButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>show()</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method to make the button active and visible.</td>
</tr>
<tr>
<td>hide()</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method to hide the button.</td>
</tr>
</tbody>
</table>
<p>All these methods return the BackButton object so they can be chained.</p>
<h4><a class="anchor" name="mainbutton" href="#mainbutton"><i class="anchor-icon"></i></a>MainButton</h4>
<p>This object controls the main button, which is displayed at the bottom of the Web App in the Telegram interface.</p>
<table class="table">
@ -326,6 +439,11 @@
<td>A method that sets the button press event handler. An alias for <code>Telegram.WebApp.onEvent(&#39;mainButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>offClick(callback) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>A method that removes the button press event handler. An alias for <code>Telegram.WebApp.offEvent(&#39;mainButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>show()</td>
<td>Function</td>
<td>A method to make the button visible.<br><em>Note that opening the Web App from the <a href="#launching-web-apps-from-the-attachment-menu">attachment menu</a> hides the main button until the user interacts with the Web App interface.</em></td>
@ -363,6 +481,35 @@
</tbody>
</table>
<p>All these methods return the MainButton object so they can be chained.</p>
<h4><a class="anchor" name="hapticfeedback" href="#hapticfeedback"><i class="anchor-icon"></i></a>HapticFeedback</h4>
<p><sup><mark>NEW</mark></sup> This object controls haptic feedback.</p>
<table class="table">
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>impactOccurred(style)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method tells that an impact occurred. The Telegram app may play the appropriate haptics based on style value passed. Style can be one of these values:<br>- <em>light</em>, indicates a collision between small or lightweight UI objects,<br>- <em>medium</em>, indicates a collision between medium-sized or medium-weight UI objects,<br>- <em>heavy</em>, indicates a collision between large or heavyweight UI objects,<br>- <em>rigid</em>, indicates a collision between hard or inflexible UI objects,<br>- <em>soft</em>, indicates a collision between soft or flexible UI objects.</td>
</tr>
<tr>
<td>notificationOccurred(type)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method tells that a task or action has succeeded, failed, or produced a warning. The Telegram app may play the appropriate haptics based on type value passed. Type can be one of these values:<br>- <em>error</em>, indicates that a task or action has failed,<br>- <em>success</em>, indicates that a task or action has completed successfully,<br>- <em>warning</em>, indicates that a task or action produced a warning.</td>
</tr>
<tr>
<td>selectionChanged()</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method tells that the user has changed a selection. The Telegram app may play the appropriate haptics.<br><br><em>Do not use this feedback when the user makes or confirms a selection; use it only when the selection changes.</em></td>
</tr>
</tbody>
</table>
<p>All these methods return the HapticFeedback object so they can be chained.</p>
<h4><a class="anchor" name="webappinitdata" href="#webappinitdata"><i class="anchor-icon"></i></a>WebAppInitData</h4>
<p>This object contains data that is transferred to the Web App when it is opened. It is empty if the Web App was launched from a <a href="#keyboard-button-web-apps">keyboard button</a>.</p>
<table class="table">
@ -387,7 +534,12 @@
<tr>
<td>receiver</td>
<td><a href="#webappuser">WebAppUser</a></td>
<td><em>Optional.</em> An object containing data about the chat partner of the current user in the chat where the bot was launched via the attachment menu. Returned only for Web Apps launched via the attachment menu.</td>
<td><em>Optional.</em> An object containing data about the chat partner of the current user in the chat where the bot was launched via the attachment menu. Returned only for private chats and only for Web Apps launched via the attachment menu.</td>
</tr>
<tr>
<td>chat <sup><mark>NEW</mark></sup></td>
<td><a href="#webappchat">WebAppChat</a></td>
<td><em>Optional.</em> An object containing data about the chat where the bot was launched via the attachment menu. Returned for supergroups, channels and group chats only for Web Apps launched via the attachment menu.</td>
</tr>
<tr>
<td>start_param</td>
@ -395,6 +547,11 @@
<td><em>Optional.</em> The value of the <em>startattach</em> parameter, passed <a href="#adding-bots-to-the-attachment-menu">via link</a>. Only returned for Web Apps when launched from the attachment menu via link.<br><br>The value of the <code>start_param</code> parameter will also be passed in the GET-parameter <code>tgWebAppStartParam</code>, so the Web App can load the correct interface right away.</td>
</tr>
<tr>
<td>can_send_after <sup><mark>NEW</mark></sup></td>
<td>Integer</td>
<td><em>Optional.</em> Time in seconds, after which a message can be sent via the <a href="/bots/api#answerwebappquery">answerWebAppQuery</a> method.</td>
</tr>
<tr>
<td>auth_date</td>
<td>Integer</td>
<td>Unix time when the form was opened.</td>
@ -454,6 +611,44 @@
</tr>
</tbody>
</table>
<h4><a class="anchor" name="webappchat" href="#webappchat"><i class="anchor-icon"></i></a>WebAppChat</h4>
<p><sup><mark>NEW</mark></sup> This object represents a chat.</p>
<table class="table">
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>Integer</td>
<td>Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.</td>
</tr>
<tr>
<td>type</td>
<td>String</td>
<td>Type of chat, can be either “group”, “supergroup” or “channel”</td>
</tr>
<tr>
<td>title</td>
<td>String</td>
<td>Title of the chat</td>
</tr>
<tr>
<td>username</td>
<td>String</td>
<td><em>Optional</em>. Username of the chat</td>
</tr>
<tr>
<td>photo_url</td>
<td>String</td>
<td><em>Optional</em>. URL of the chats photo. The photo can be in .jpeg or .svg formats. Only returned for Web Apps launched from the attachment menu.</td>
</tr>
</tbody>
</table>
<h4><a class="anchor" name="validating-data-received-via-the-web-app" href="#validating-data-received-via-the-web-app"><i class="anchor-icon"></i></a>Validating data received via the Web App</h4>
<p>To validate data received via the Web App, one should send the data from the <em>Telegram.WebApp.initData</em> field to the bot&#39;s backend. The data is a query string, which is composed of a series of field-value pairs.</p>
<p>You can verify the integrity of the data received by comparing the received <em>hash</em> parameter with the hexadecimal representation of the <a href="https://en.wikipedia.org/wiki/Hash-based_message_authentication_code">HMAC-SHA-256</a> signature of the <strong>data-check-string</strong> with the secret key, which is the <a href="https://en.wikipedia.org/wiki/Hash-based_message_authentication_code">HMAC-SHA-256</a> signature of the <a href="/bots#creating-a-new-bot">bot&#39;s token</a> with the constant string <code>WebAppData</code> used as a key.</p>
@ -488,6 +683,18 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
<td><code>mainButtonClicked</code></td>
<td>Occurs when the <a href="#mainbutton">main button</a> is pressed.<br><em>eventHandler</em> receives no parameters.</td>
</tr>
<tr>
<td><code>backButtonClicked</code> <sup><mark>NEW</mark></sup></td>
<td><mark>Bot API 6.1+</mark> Occurrs when the <a href="#backbutton">back button</a> is pressed.<br><em>eventHandler</em> receives no parameters.</td>
</tr>
<tr>
<td><code>settingsButtonClicked</code> <sup><mark>NEW</mark></sup></td>
<td><mark>Bot API 6.1+</mark> Occurrs when the Settings item in context menu is pressed.<br><em>eventHandler</em> receives no parameters.</td>
</tr>
<tr>
<td><code>invoiceClosed</code> <sup><mark>NEW</mark></sup></td>
<td><mark>Bot API 6.1+</mark> Occurrs when the opened invoice is closed.<br><em>eventHandler</em> receives an object with the two fields: <em>url</em> invoice link provided and <em>status</em> one of the invoice statuses:<br>- <strong>paid</strong> invoice was paid successfully,<br>- <strong>cancelled</strong> user closed this invoice without paying,<br>- <strong>failed</strong> user tried to pay, but the payment was failed,<br>- <strong>pending</strong> the payment is still processing. The bot will receive a service message about a <a href="https://core.telegram.org/bots/api#successfulpayment">successful payment</a> when the payment is successfully paid.</td>
</tr>
</tbody>
</table>
<h4><a class="anchor" name="adding-bots-to-the-attachment-menu" href="#adding-bots-to-the-attachment-menu"><i class="anchor-icon"></i></a>Adding Bots to the Attachment Menu</h4>
@ -501,6 +708,9 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
<p>The following link formats are also supported:</p>
<p><code>https://t.me/username?attach=botusername</code><br><code>https://t.me/username?attach=botusername&amp;startattach=command</code><br><code>https://t.me/+1234567890?attach=botusername</code><br><code>https://t.me/+1234567890?attach=botusername&amp;startattach=command</code></p>
<p>These links open the Web App in the attachment menu in the chat with a specific user. If the bot wasn&#39;t already added to the attachment menu, the user will be prompted to do so. If a non-empty <em>startattach</em> parameter was included in the link, it will be passed to the Web App in the <em>start_param</em> field and in the GET parameter <em>tgWebAppStartParam</em>.</p>
<p><mark>Bot API 6.1+</mark> supports a new link format:</p>
<p><code>https://t.me/botusername?startattach&amp;choose=users+bots</code><br><code>https://t.me/botusername?startattach=command&amp;choose=groups+channels</code></p>
<p>Opening such a link prompts the user to choose a specific chat and opens the attachment menu in that chat. If the bot wasn&#39;t already added to the attachment menu, the user will be prompted to do so. You can specify which types of chats the user will be able to choose from. It can be one or more of the following types: <em>users</em>, <em>bots</em>, <em>groups</em>, <em>channels</em> separated by a <code>+</code> sign. If a non-empty <em>startattach</em> parameter was included in the link, it will be passed to the Web App in the <em>start_param</em> field and in the GET parameter <em>tgWebAppStartParam</em>.</p>
<h3><a class="anchor" name="testing-web-apps" href="#testing-web-apps"><i class="anchor-icon"></i></a>Testing Web Apps</h3>
<h4><a class="anchor" name="using-bots-in-the-test-environment" href="#using-bots-in-the-test-environment"><i class="anchor-icon"></i></a>Using bots in the test environment</h4>
<p>To log in to the test environment, use either of the following:</p>
@ -511,10 +721,31 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
</ul>
<p>The test environment is completely separate from the main environment, so you will need to create a <strong>new user account</strong> and a <strong>new bot</strong> with @BotFather.</p>
<p>After receiving your bot token, you can send requests to the Bot API in this format: </p>
<p><code>https://api.telegram.org/bot&lt;token&gt;/test/METHOD_NAME</code></p>
<pre><code>https://api.telegram.org/bot&lt;token&gt;/test/METHOD_NAME</code></pre>
<blockquote>
<p><strong>Note:</strong> When working with the test environment, you may use HTTP links without TLS to test your Web App.</p>
</blockquote>
<h4><a class="anchor" name="debug-mode-for-web-apps" href="#debug-mode-for-web-apps"><i class="anchor-icon"></i></a>Debug Mode for Web Apps</h4>
<p>Use these tools to find app-specific issues in your Web App:</p>
<p><strong>Android</strong></p>
<ul>
<li><a href="https://developer.chrome.com/docs/devtools/remote-debugging/">Enable USB-Debugging</a> on your device.</li>
<li>In Telegram Settings, scroll all the way down, press and hold on the <strong>version number</strong> two times.</li>
<li>Choose <em>Enable WebView Debug</em> in the Debug Settings.</li>
<li>Connect your phone to your computer and open <code>chrome://inspect/#devices</code> in Chrome you will see your Web App there when you launch it on your phone.</li>
</ul>
<p><strong>Telegram Desktop on Windows and Linux</strong></p>
<ul>
<li>Download and launch the <a href="https://desktop.telegram.org/changelog#beta-version">Beta Version</a> of Telegram Desktop on <strong>Windows</strong> or <strong>Linux</strong> (not supported on Telegram Desktop for macOS yet).</li>
<li>Go to <em>Settings &gt; Advanced &gt; Experimental settings &gt; Enable webview inspection</em>.</li>
<li>Right click in the WebView and choose <em>Inspect</em>.</li>
</ul>
<p><strong>Telegram macOS</strong></p>
<ul>
<li>Download and launch the <a href="https://telegram.org/dl/macos/beta">Beta Version</a> of Telegram macOS.</li>
<li>Quickly click 5 times on the Settings icon to open the debug menu and enable “Debug Web Apps”.</li>
<li>Right click in the web app and choose <em>Inspect Element</em>.</li>
</ul>
</div>
</div>

View file

@ -54,6 +54,43 @@ To learn how to create…">
<blockquote>
<p>Subscribe to <a href="https://t.me/botnews">@BotNews</a> to be the first to know about the latest updates and join the discussion in <a href="https://t.me/bottalk">@BotTalk</a></p>
</blockquote>
<h3><a class="anchor" name="june-20-2022" href="#june-20-2022"><i class="anchor-icon"></i></a>June 20, 2022</h3>
<p><strong>Bot API 6.1</strong></p>
<p><strong>Media in Descriptions</strong></p>
<ul>
<li>Added support for photos and videos in the &#39;What can this bot do?&#39; section (shown on the bot&#39;s start screen). Use <a href="https://t.me/BotFather">BotFather</a> to set up media.</li>
</ul>
<p><strong>Web App Improvements</strong></p>
<ul>
<li>Added the fields <em>version</em>, <em>headerColor</em>, <em>backgroundColor</em>, <em>BackButton</em>, <em>HapticFeedback</em> and the methods <em>isVersionAtLeast</em>, <em>setHeaderColor</em>, <em>setBackgroundColor</em>, <em>openLink</em>, <em>openTelegramLink</em>, <em>openInvoice</em> to the class <a href="/bots/webapps#initializing-web-apps">WebApp</a>.</li>
<li>Added the field <em>secondary_bg_color</em> to the class <a href="/bots/webapps#themeparams">ThemeParams</a>.</li>
<li>Added the method <em>offClick</em> to the class <a href="/bots/webapps#mainbutton">MainButton</a>.</li>
<li>Added the fields <em>chat</em>, <em>can_send_after</em> to the class <a href="/bots/webapps#webappinitdata">WebAppInitData</a>.</li>
<li>Added the events <em>backButtonClicked</em>, <em>settingsButtonClicked</em>, <em>invoiceClosed</em>.</li>
</ul>
<p><strong>Join Requests &amp; Payments</strong></p>
<ul>
<li>Added the fields <em>join_to_send_messages</em> and <em>join_by_request</em> to the class <a href="/bots/api#chat">Chat</a>.</li>
<li>Added the ability to process join requests which were created <a href="https://telegram.org/blog/700-million-and-premium#join-requests-for-public-groups">without an invite link</a>. Bots will receive a “chat_join_request” update as usual.</li>
<li>Added the method <a href="/bots/api#createinvoicelink">createInvoiceLink</a> to generate an HTTP link for an invoice.</li>
</ul>
<p><strong>Telegram Premium Support</strong> (<a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">more info</a>)</p>
<ul>
<li>The maximum value of the field <em>file_size</em> in the classes <a href="/bots/api#animation">Animation</a>, <a href="/bots/api#audio">Audio</a>, <a href="/bots/api#document">Document</a>, <a href="/bots/api#video">Video</a>, <a href="/bots/api#voice">Voice</a>, and <a href="/bots/api#file">File</a> can no longer be stored in a signed 32-bit integer type. This change is necessary to support 4GB files uploaded by <a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">premium accounts</a>.</li>
<li>Added the field <em>is_premium</em> to the class <a href="/bots/api#user">User</a>.</li>
<li>Added the field <em>premium_animation</em> to the class <a href="/bots/api#sticker">Sticker</a>.</li>
</ul>
<p><strong>Attachment Menu Integration</strong></p>
<ul>
<li>Added the field <em>added_to_attachment_menu</em> to the class <a href="/bots/api#user">User</a>.</li>
<li>Bots integrated in the attachment menu can now be used in groups, supergroups and channels.</li>
<li>Added support for t.me links that can be used to select the chat in which the attachment menu with the bot will be opened.</li>
</ul>
<p><strong>Other Changes</strong></p>
<ul>
<li>Added the parameter <em>secret_token</em> to the method <a href="/bots/api#setwebhook">setWebhook</a>.</li>
<li>As previously announced, only HTTPS links are now allowed in <em>login_url</em> inline keyboard buttons.</li>
</ul>
<h3><a class="anchor" name="april-16-2022" href="#april-16-2022"><i class="anchor-icon"></i></a>April 16, 2022</h3>
<p><strong>Bot API 6.0</strong></p>
<ul>

View file

@ -53,6 +53,43 @@ To learn how to create…">
<blockquote>
<p>Subscribe to <a href="https://t.me/botnews">@BotNews</a> to be the first to know about the latest updates and join the discussion in <a href="https://t.me/bottalk">@BotTalk</a></p>
</blockquote>
<h4><a class="anchor" name="june-20-2022" href="#june-20-2022"><i class="anchor-icon"></i></a>June 20, 2022</h4>
<p><strong>Bot API 6.1</strong></p>
<p><strong>Media in Descriptions</strong></p>
<ul>
<li>Added support for photos and videos in the &#39;What can this bot do?&#39; section (shown on the bot&#39;s start screen). Use <a href="https://t.me/BotFather">BotFather</a> to set up media.</li>
</ul>
<p><strong>Web App Improvements</strong></p>
<ul>
<li>Added the fields <em>version</em>, <em>headerColor</em>, <em>backgroundColor</em>, <em>BackButton</em>, <em>HapticFeedback</em> and the methods <em>isVersionAtLeast</em>, <em>setHeaderColor</em>, <em>setBackgroundColor</em>, <em>openLink</em>, <em>openTelegramLink</em>, <em>openInvoice</em> to the class <a href="/bots/webapps#initializing-web-apps">WebApp</a>.</li>
<li>Added the field <em>secondary_bg_color</em> to the class <a href="/bots/webapps#themeparams">ThemeParams</a>.</li>
<li>Added the method <em>offClick</em> to the class <a href="/bots/webapps#mainbutton">MainButton</a>.</li>
<li>Added the fields <em>chat</em>, <em>can_send_after</em> to the class <a href="/bots/webapps#webappinitdata">WebAppInitData</a>.</li>
<li>Added the events <em>backButtonClicked</em>, <em>settingsButtonClicked</em>, <em>invoiceClosed</em>.</li>
</ul>
<p><strong>Join Requests &amp; Payments</strong></p>
<ul>
<li>Added the fields <em>join_to_send_messages</em> and <em>join_by_request</em> to the class <a href="#chat">Chat</a>.</li>
<li>Added the ability to process join requests which were created <a href="https://telegram.org/blog/700-million-and-premium#join-requests-for-public-groups">without an invite link</a>. Bots will receive a “chat_join_request” update as usual.</li>
<li>Added the method <a href="#createinvoicelink">createInvoiceLink</a> to generate an HTTP link for an invoice.</li>
</ul>
<p><strong>Telegram Premium Support</strong> (<a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">more info</a>)</p>
<ul>
<li>The maximum value of the field <em>file_size</em> in the classes <a href="#animation">Animation</a>, <a href="#audio">Audio</a>, <a href="#document">Document</a>, <a href="#video">Video</a>, <a href="#voice">Voice</a>, and <a href="#file">File</a> can no longer be stored in a signed 32-bit integer type. This change is necessary to support 4GB files uploaded by <a href="https://telegram.org/blog/700-million-and-premium#telegram-premium">premium accounts</a>.</li>
<li>Added the field <em>is_premium</em> to the class <a href="#user">User</a>.</li>
<li>Added the field <em>premium_animation</em> to the class <a href="#sticker">Sticker</a>.</li>
</ul>
<p><strong>Attachment Menu Integration</strong></p>
<ul>
<li>Added the field <em>added_to_attachment_menu</em> to the class <a href="#user">User</a>.</li>
<li>Bots integrated in the attachment menu can now be used in groups, supergroups and channels.</li>
<li>Added support for t.me links that can be used to select the chat in which the attachment menu with the bot will be opened.</li>
</ul>
<p><strong>Other Changes</strong></p>
<ul>
<li>Added the parameter <em>secret_token</em> to the method <a href="#setwebhook">setWebhook</a>.</li>
<li>As previously announced, only HTTPS links are now allowed in <em>login_url</em> inline keyboard buttons.</li>
</ul>
<h4><a class="anchor" name="april-16-2022" href="#april-16-2022"><i class="anchor-icon"></i></a>April 16, 2022</h4>
<p><strong>Bot API 6.0</strong></p>
<ul>
@ -89,19 +126,6 @@ To learn how to create…">
<li>Added new <a href="#messageentity">MessageEntity</a> type “spoiler”.</li>
<li>Added the ability to specify spoiler entities using <a href="#html-style">HTML</a> and <a href="#markdownv2-style">MarkdownV2</a> formatting options.</li>
</ul>
<h4><a class="anchor" name="december-7-2021" href="#december-7-2021"><i class="anchor-icon"></i></a>December 7, 2021</h4>
<p><strong>Bot API 5.5</strong></p>
<ul>
<li>Bots are now allowed to contact users who sent a join request to a chat where the bot is an administrator with the <em>can_invite_users</em> administrator right even if the user never interacted with the bot before.</li>
<li>Added support for mentioning users by their ID in inline keyboards. This will only work in Telegram versions released after December 7, 2021. Older clients will display <em>unsupported message</em>.</li>
<li>Added the methods <a href="#banchatsenderchat">banChatSenderChat</a> and <a href="#unbanchatsenderchat">unbanChatSenderChat</a> for banning and unbanning channel chats in supergroups and channels.</li>
<li>Added the field <em>has_private_forwards</em> to the class <a href="#chat">Chat</a> for private chats, which can be used to check the possibility of mentioning the user by their ID.</li>
<li>Added the field <em>has_protected_content</em> to the classes <a href="#chat">Chat</a> and <a href="#message">Message</a>.</li>
<li>Added the field <em>is_automatic_forward</em> to the class <a href="#message">Message</a>.</li>
</ul>
<p><strong>Note:</strong> After this update it will become impossible to forward messages from some chats. Use the fields <em>has_protected_content</em> in the classes <a href="#message">Message</a> and <a href="#chat">Chat</a> to check this.</p>
<p><strong>Note:</strong> After this update users are able to send messages on behalf of channels they own. Bots are expected to use the field <em>sender_chat</em> in the class <a href="#message">Message</a> to correctly support such messages.</p>
<p><strong>Note:</strong> As previously announced, user identifiers can now have up to 52 significant bits and require a 64-bit integer or double-precision float type to be stored safely.</p>
<p><strong><a href="/bots/api-changelog">See earlier changes »</a></strong></p>
<h3><a class="anchor" name="authorizing-your-bot" href="#authorizing-your-bot"><i class="anchor-icon"></i></a>Authorizing your bot</h3>
<p>Each bot is given a unique authentication token <a href="/bots#6-botfather">when it is created</a>. The token looks something like <code>123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11</code>, but we&#39;ll use simply <strong>&lt;token&gt;</strong> in this document instead. You can learn about obtaining tokens and generating new ones in <a href="https://core.telegram.org/bots#6-botfather">this document</a>.</p>
@ -273,7 +297,7 @@ To learn how to create…">
</blockquote>
<h4><a class="anchor" name="setwebhook" href="#setwebhook"><i class="anchor-icon"></i></a>setWebhook</h4>
<p>Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized <a href="#update">Update</a>. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns <em>True</em> on success.</p>
<p>If you&#39;d like to make sure that the webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. <code>https://www.example.com/&lt;token&gt;</code>. Since nobody else knows your bot&#39;s token, you can be pretty sure it&#39;s us.</p>
<p>If you&#39;d like to make sure that the webhook was set by you, you can specify secret data in the parameter <em>secret_token</em>. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.</p>
<table class="table">
<thead>
<tr>
@ -320,11 +344,17 @@ To learn how to create…">
<td>Optional</td>
<td>Pass <em>True</em> to drop all pending updates</td>
</tr>
<tr>
<td>secret_token</td>
<td>String</td>
<td>Optional</td>
<td>A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters <code>A-Z</code>, <code>a-z</code>, <code>0-9</code>, <code>_</code> and <code>-</code> are allowed. The header is useful to ensure that the request comes from a webhook set by you.</td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>Notes</strong><br><strong>1.</strong> You will not be able to receive updates using <a href="#getupdates">getUpdates</a> for as long as an outgoing webhook is set up.<br><strong>2.</strong> To use a self-signed certificate, you need to upload your <a href="/bots/self-signed">public key certificate</a> using <em>certificate</em> parameter. Please upload as InputFile, sending a String will not work.<br><strong>3.</strong> Ports currently supported <em>for webhooks</em>: <strong>443, 80, 88, 8443</strong>.</p>
<p><strong>NEW!</strong> If you&#39;re having any trouble setting up webhooks, please check out this <a href="/bots/webhooks">amazing guide to webhooks</a>.</p>
<p>If you&#39;re having any trouble setting up webhooks, please check out this <a href="/bots/webhooks">amazing guide to webhooks</a>.</p>
</blockquote>
<h4><a class="anchor" name="deletewebhook" href="#deletewebhook"><i class="anchor-icon"></i></a>deleteWebhook</h4>
<p>Use this method to remove webhook integration if you decide to switch back to <a href="#getupdates">getUpdates</a>. Returns <em>True</em> on success.</p>
@ -454,6 +484,16 @@ To learn how to create…">
<td><em>Optional</em>. <a href="https://en.wikipedia.org/wiki/IETF_language_tag">IETF language tag</a> of the user&#39;s language</td>
</tr>
<tr>
<td>is_premium</td>
<td>True</td>
<td><em>Optional</em>. <em>True</em>, if this user is a Telegram Premium user</td>
</tr>
<tr>
<td>added_to_attachment_menu</td>
<td>True</td>
<td><em>Optional</em>. <em>True</em>, if this user added the bot to the attachment menu</td>
</tr>
<tr>
<td>can_join_groups</td>
<td>Boolean</td>
<td><em>Optional</em>. <em>True</em>, if the bot can be invited to groups. Returned only in <a href="#getme">getMe</a>.</td>
@ -527,6 +567,16 @@ To learn how to create…">
<td><em>Optional</em>. <em>True</em>, if privacy settings of the other party in the private chat allows to use <code>tg://user?id=&lt;user_id&gt;</code> links only in chats with the user. Returned only in <a href="#getchat">getChat</a>.</td>
</tr>
<tr>
<td>join_to_send_messages</td>
<td>True</td>
<td><em>Optional</em>. <em>True</em>, if users need to join the supergroup before they can send messages. Returned only in <a href="#getchat">getChat</a>.</td>
</tr>
<tr>
<td>join_by_request</td>
<td>True</td>
<td><em>Optional</em>. <em>True</em>, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in <a href="#getchat">getChat</a>.</td>
</tr>
<tr>
<td>description</td>
<td>String</td>
<td><em>Optional</em>. Description, for groups, supergroups and channel chats. Returned only in <a href="#getchat">getChat</a>.</td>
@ -687,7 +737,7 @@ To learn how to create…">
<tr>
<td>text</td>
<td>String</td>
<td><em>Optional</em>. For text messages, the actual UTF-8 text of the message, 0-4096 characters</td>
<td><em>Optional</em>. For text messages, the actual UTF-8 text of the message</td>
</tr>
<tr>
<td>entities</td>
@ -737,7 +787,7 @@ To learn how to create…">
<tr>
<td>caption</td>
<td>String</td>
<td><em>Optional</em>. Caption for the animation, audio, document, photo, video or voice, 0-1024 characters</td>
<td><em>Optional</em>. Caption for the animation, audio, document, photo, video or voice</td>
</tr>
<tr>
<td>caption_entities</td>
@ -1942,7 +1992,7 @@ To learn how to create…">
<tr>
<td>login_url</td>
<td><a href="#loginurl">LoginUrl</a></td>
<td><em>Optional</em>. An HTTP URL used to automatically authorize the user. Can be used as a replacement for the <a href="https://core.telegram.org/widgets/login">Telegram Login Widget</a>.</td>
<td><em>Optional</em>. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the <a href="https://core.telegram.org/widgets/login">Telegram Login Widget</a>.</td>
</tr>
<tr>
<td>switch_inline_query</td>
@ -6241,6 +6291,11 @@ pre-formatted fixed-width code block written in the Python programming language
<td><em>Optional</em>. Name of the sticker set to which the sticker belongs</td>
</tr>
<tr>
<td>premium_animation</td>
<td><a href="#file">File</a></td>
<td><em>Optional</em>. Premium animation for the sticker, if the sticker is premium</td>
</tr>
<tr>
<td>mask_position</td>
<td><a href="#maskposition">MaskPosition</a></td>
<td><em>Optional</em>. For mask stickers, the position where the mask should be placed</td>
@ -8663,6 +8718,140 @@ pre-formatted fixed-width code block written in the Python programming language
</tr>
</tbody>
</table>
<h4><a class="anchor" name="createinvoicelink" href="#createinvoicelink"><i class="anchor-icon"></i></a>createInvoiceLink</h4>
<p>Use this method to create a link for an invoice. Returns the created invoice link as <em>String</em> on success.</p>
<table class="table">
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>title</td>
<td>String</td>
<td>Yes</td>
<td>Product name, 1-32 characters</td>
</tr>
<tr>
<td>description</td>
<td>String</td>
<td>Yes</td>
<td>Product description, 1-255 characters</td>
</tr>
<tr>
<td>payload</td>
<td>String</td>
<td>Yes</td>
<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>
</tr>
<tr>
<td>provider_token</td>
<td>String</td>
<td>Yes</td>
<td>Payment provider token, obtained via <a href="https://t.me/botfather">BotFather</a></td>
</tr>
<tr>
<td>currency</td>
<td>String</td>
<td>Yes</td>
<td>Three-letter ISO 4217 currency code, see <a href="/bots/payments#supported-currencies">more on currencies</a></td>
</tr>
<tr>
<td>prices</td>
<td>Array of <a href="#labeledprice">LabeledPrice</a></td>
<td>Yes</td>
<td>Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)</td>
</tr>
<tr>
<td>max_tip_amount</td>
<td>Integer</td>
<td>Optional</td>
<td>The maximum accepted amount for tips in the <em>smallest units</em> of the currency (integer, <strong>not</strong> float/double). For example, for a maximum tip of <code>US$ 1.45</code> pass <code>max_tip_amount = 145</code>. See the <em>exp</em> parameter in <a href="https://core.telegram.org/bots/payments/currencies.json">currencies.json</a>, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0</td>
</tr>
<tr>
<td>suggested_tip_amounts</td>
<td>Array of Integer</td>
<td>Optional</td>
<td>A JSON-serialized array of suggested amounts of tips in the <em>smallest units</em> of the currency (integer, <strong>not</strong> float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed <em>max_tip_amount</em>.</td>
</tr>
<tr>
<td>provider_data</td>
<td>String</td>
<td>Optional</td>
<td>JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.</td>
</tr>
<tr>
<td>photo_url</td>
<td>String</td>
<td>Optional</td>
<td>URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.</td>
</tr>
<tr>
<td>photo_size</td>
<td>Integer</td>
<td>Optional</td>
<td>Photo size in bytes</td>
</tr>
<tr>
<td>photo_width</td>
<td>Integer</td>
<td>Optional</td>
<td>Photo width</td>
</tr>
<tr>
<td>photo_height</td>
<td>Integer</td>
<td>Optional</td>
<td>Photo height</td>
</tr>
<tr>
<td>need_name</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if you require the user&#39;s full name to complete the order</td>
</tr>
<tr>
<td>need_phone_number</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if you require the user&#39;s phone number to complete the order</td>
</tr>
<tr>
<td>need_email</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if you require the user&#39;s email address to complete the order</td>
</tr>
<tr>
<td>need_shipping_address</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if you require the user&#39;s shipping address to complete the order</td>
</tr>
<tr>
<td>send_phone_number_to_provider</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if the user&#39;s phone number should be sent to the provider</td>
</tr>
<tr>
<td>send_email_to_provider</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if the user&#39;s email address should be sent to the provider</td>
</tr>
<tr>
<td>is_flexible</td>
<td>Boolean</td>
<td>Optional</td>
<td>Pass <em>True</em>, if the final price depends on the shipping method</td>
</tr>
</tbody>
</table>
<h4><a class="anchor" name="answershippingquery" href="#answershippingquery"><i class="anchor-icon"></i></a>answerShippingQuery</h4>
<p>If you sent an invoice requesting a shipping address and the parameter <em>is_flexible</em> was specified, the Bot API will send an <a href="#update">Update</a> with a <em>shipping_query</em> field to the bot. Use this method to reply to shipping queries. On success, <em>True</em> is returned.</p>
<table class="table">

View file

@ -56,6 +56,19 @@
<p>To see a <strong>Web App</strong> in action, try our sample <a href="https://t.me/durgerkingbot">@DurgerKingBot</a>.</p>
</blockquote>
<hr>
<h3><a class="anchor" name="recent-changes" href="#recent-changes"><i class="anchor-icon"></i></a>Recent changes</h3>
<h4><a class="anchor" name="june-20-2022" href="#june-20-2022"><i class="anchor-icon"></i></a>June 20, 2022</h4>
<p><strong>Bot API 6.1</strong></p>
<ul>
<li>Added the ability to use bots added to the attachment menu in group, supergroup and channel chats.</li>
<li>Added support for <a href="#adding-bots-to-the-attachment-menu">t.me links</a> that can be used to select the chat in which the attachment menu with the bot will be opened.</li>
<li>Added the fields <em>version</em>, <em>headerColor</em>, <em>backgroundColor</em>, <em>BackButton</em>, <em>HapticFeedback</em> and the methods <em>isVersionAtLeast</em>, <em>setHeaderColor</em>, <em>setBackgroundColor</em>, <em>openLink</em>, <em>openTelegramLink</em>, <em>openInvoice</em> to the class <a href="#initializing-web-apps">WebApp</a>.</li>
<li>Added the field <em>secondary_bg_color</em> to the class <a href="#themeparams">ThemeParams</a>.</li>
<li>Added the method <em>offClick</em> to the class <a href="#mainbutton">MainButton</a>.</li>
<li>Added the fields <em>chat</em>, <em>can_send_after</em> to the class <a href="#webappinitdata">WebAppInitData</a>.</li>
<li>Added the <a href="#events-available-for-web-apps">events</a> <em>backButtonClicked</em>, <em>settingsButtonClicked</em>, <em>invoiceClosed</em>.</li>
</ul>
<hr>
<h3><a class="anchor" name="designing-web-apps" href="#designing-web-apps"><i class="anchor-icon"></i></a>Designing Web Apps</h3>
<h4><a class="anchor" name="color-schemes" href="#color-schemes"><i class="anchor-icon"></i></a>Color Schemes</h4>
<p>Web Apps always receive data about the user&#39;s current <strong>color theme</strong> in real time, so you can adjust the appearance of your interfaces to match it. For example, when users switch between <strong>Day and Night</strong> modes or use various <a href="https://telegram.org/blog/protected-content-delete-by-date-and-more#global-chat-themes-on-android">custom themes</a>.</p>
@ -131,13 +144,14 @@
</blockquote>
<h4><a class="anchor" name="launching-web-apps-from-the-attachment-menu" href="#launching-web-apps-from-the-attachment-menu"><i class="anchor-icon"></i></a>Launching Web Apps from the Attachment Menu</h4>
<blockquote>
<p><strong>TL;DR:</strong> Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from any private chat. To try this mode, open this <a href="https://t.me/durgerkingbot?startattach">attachment menu link</a> for <em>@DurgerKingBot</em>, then use the <img class="icon" src="/file/464001085/2/E4hNXSNQimQ.2503/bf6ffcab3cb3afd43d" alt="Attach"> menu in any <strong>private chat</strong>.</p>
<p><strong>TL;DR:</strong> Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from any chat. To try this mode, open this <a href="https://t.me/durgerkingbot?startattach">attachment menu link</a> for <em>@DurgerKingBot</em>, then use the <img class="icon" src="/file/464001085/2/E4hNXSNQimQ.2503/bf6ffcab3cb3afd43d" alt="Attach"> menu in <strong>any type of chat</strong>.</p>
</blockquote>
<p>Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from <strong>any private chat</strong> (with either a <em>user</em> or <em>another bot</em>).</p>
<p>Web App Bots can request to be added directly to a user&#39;s attachment menu, allowing them to be quickly launched from <strong>any type of chat</strong>. <sup><mark>NEW</mark></sup> You can configure in which types of chats your web app can be started from the attachment menu (private, groups, supergroups or channels).</p>
<p>Attachment menu integration is currently only available for major advertisers on the <a href="https://promote.telegram.org/basics">Telegram Ad Platform</a>. However, <strong>all bots</strong> can use it in the <a href="#using-bots-in-the-test-environment">test server environment</a>.</p>
<p>To enable this feature for your bot, open <a href="https://t.me/botfather">@BotFather</a> <a href="#using-bots-in-the-test-environment">from an account on the test server</a> and send the <code>/setattach</code> command or go to <em>Bot Settings &gt; Configure Attachment Menu</em>. Then specify the URL that will be opened to launch the bot&#39;s Web App via its icon in the attachment menu.</p>
<p>In addition to the user&#39;s <a href="#color-schemes">theme settings</a>, the bot will receive basic user information (<code>ID</code>, <code>name</code>, <code>username</code>, <code>language_code</code>, <code>photo</code>), as well as public info about the chat partner (<code>ID</code>, <code>name</code>, <code>username</code>, <code>photo</code>) and a unique identifier for the web view session <strong>query_id</strong>, which allows messages of any type to be sent to the chat on behalf of the user that opened the bot.</p>
<p>The bot can call the Bot API method <a href="/bots/api#answerwebappquery">answerWebAppQuery</a>, which sends an inline message from the user via the bot to the private chat where it was launched and closes the Web App.</p>
<p><sup><mark>NEW</mark></sup> You can add a &#39;Settings&#39; item to the context menu of your Web App using <a href="https://t.me/botfather">@BotFather</a>. When users select this option from the menu, your bot will receive a <code>settingsButtonClicked</code> event.</p>
<p>In addition to the user&#39;s <a href="#color-schemes">theme settings</a>, the bot will receive basic user information (<code>ID</code>, <code>name</code>, <code>username</code>, <code>language_code</code>, <code>photo</code>), as well as public info about the chat partner (<code>ID</code>, <code>name</code>, <code>username</code>, <code>photo</code>) or the chat info (<code>ID</code>, <code>type</code>, <code>title</code>, <code>username</code>, <code>photo</code>) and a unique identifier for the web view session <strong>query_id</strong>, which allows messages of any type to be sent to the chat on behalf of the user that opened the bot.</p>
<p>The bot can call the Bot API method <a href="/bots/api#answerwebappquery">answerWebAppQuery</a>, which sends an inline message from the user via the bot to the chat where it was launched and closes the Web App.</p>
<blockquote>
<p>You can read more about adding bots to the attachment menu <a href="#adding-bots-to-the-attachment-menu">here</a>.</p>
</blockquote>
@ -166,6 +180,11 @@
<td>An object with input data transferred to the Web App.<br><strong>WARNING:</strong> Data from this field should not be trusted. You should only use data from <em>initData</em> on the bot&#39;s server and only after it has been <a href="#validating-data-received-via-the-web-app">validated</a>.</td>
</tr>
<tr>
<td>version <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td>The version of the Bot API available in the user&#39;s Telegram app.</td>
</tr>
<tr>
<td>colorScheme</td>
<td>String</td>
<td>The color scheme currently used in the Telegram app. Either “light” or “dark”.<br>Also available as the CSS variable <code>var(--tg-color-scheme)</code>.</td>
@ -191,11 +210,46 @@
<td>The height of the visible area of the Web App in its last stable state. Also available in CSS as a variable <code>var(--tg-viewport-stable-height)</code>.<br><br>The application can display just the top part of the Web App, with its lower part remaining outside the screen area. From this position, the user can “pull” the Web App to its maximum height, while the bot can do the same by calling the <strong>expand()</strong> method. Unlike the value of <code>viewportHeight</code>, the value of <code>viewportStableHeight</code> does not change as the position of the Web App changes with user gestures or during animations. The value of <code>viewportStableHeight</code> will be updated after all gestures and animations are completed and the Web App reaches its final size.<br><br><em>Note the <a href="#events-available-for-web-apps">event</a> <code>viewportChanged</code> with the passed parameter <code>isStateStable=true</code>, which will allow you to track when the stable state of the height of the visible area changes.</em></td>
</tr>
<tr>
<td>headerColor <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td>Current header color in the <code>#RRGGBB</code> format.</td>
</tr>
<tr>
<td>backgroundColor <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td>Current background color in the <code>#RRGGBB</code> format.</td>
</tr>
<tr>
<td>BackButton <sup><mark>NEW</mark></sup></td>
<td><a href="#backbutton">BackButton</a></td>
<td>An object for controlling the back button which can be displayed in the header of the Web App in the Telegram interface.</td>
</tr>
<tr>
<td>MainButton</td>
<td><a href="#mainbutton">MainButton</a></td>
<td>An object for controlling the main button, which is displayed at the bottom of the Web App in the Telegram interface.</td>
</tr>
<tr>
<td>HapticFeedback <sup><mark>NEW</mark></sup></td>
<td><a href="#hapticfeedback">HapticFeedback</a></td>
<td>An object for controlling haptic feedback.</td>
</tr>
<tr>
<td>isVersionAtLeast(version) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>Returns true if the user&#39;s app supports a version of the Bot API that is equal to or higher than the version passed as the parameter.</td>
</tr>
<tr>
<td>setHeaderColor(color) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that sets the app header color. You can only pass <em>Telegram.WebApp.themeParams.bg_color</em> or <em>Telegram.WebApp.themeParams.secondary_bg_color</em> as a color or you can use keywords <em>bg_color</em>, <em>secondary_bg_color</em> instead.</td>
</tr>
<tr>
<td>setBackgroundColor(color) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that sets the app background color in the <code>#RRGGBB</code> format or you can use keywords <em>bg_color</em>, <em>secondary_bg_color</em> instead.</td>
</tr>
<tr>
<td>onEvent(eventType, eventHandler)</td>
<td>Function</td>
<td>A method that sets the app event handler. Check <a href="#events-available-for-web-apps">the list of available events</a>.</td>
@ -211,6 +265,21 @@
<td>A method used to send data to the bot. When this method is called, a service message is sent to the bot containing the data <em>data</em> of the length up to 4096 bytes, and the Web App is closed. See the field <em>web_app_data</em> in the class <a href="/bots/api#message">Message</a>.<br><br><em>This method is only available for Web Apps launched via a <a href="#keyboard-button-web-apps">Keyboard button</a>.</em></td>
</tr>
<tr>
<td>openLink(url) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>A method that opens a link in an external browser. The Web App will <em>not</em> be closed.<br><br><em>Note that this method can be called only in response to the user interaction with the Web App interface (e.g. click inside the Web App or on the main button)</em></td>
</tr>
<tr>
<td>openTelegramLink(url) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>A method that opens a telegram link inside Telegram app. The Web App <em>will</em> be closed.</td>
</tr>
<tr>
<td>openInvoice(url[, callback]) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that opens an invoice using the link <em>url</em>. The Web App will receive the <a href="#events-available-for-web-apps">event</a> <em>invoiceClosed</em> when the invoice is closed. If an optional <em>callback</em> parameter was passed, the <em>callback</em> function will be called and the invoice status will be passed as the first argument.</td>
</tr>
<tr>
<td>ready()</td>
<td>Function</td>
<td>A method that informs the Telegram app that the Web App is ready to be displayed.<br>It is recommended to call this method as early as possible, as soon as all essential interface elements are loaded. Once this method is called, the loading placeholder is hidden and the Web App is shown.<br>If the method is not called, the placeholder will be hidden only when the page is fully loaded.</td>
@ -268,12 +337,56 @@
<td>String</td>
<td><em>Optional</em>. Button text color in the <code>#RRGGBB</code> format.<br>Also available as the CSS variable <code>var(--tg-theme-button-text-color)</code>.</td>
</tr>
<tr>
<td>secondary_bg_color <sup><mark>NEW</mark></sup></td>
<td>String</td>
<td><em>Optional</em>. <mark>Bot API 6.1+</mark> Secondary background color in the <code>#RRGGBB</code> format.<br>Also available as the CSS variable <code>var(--tg-theme-secondary-bg-color)</code>.</td>
</tr>
</tbody>
</table>
<div class="blog_image_wrap blog_medium_image_wrap">
<a href="/file/464001058/109a6/XLMi7E5_IvY.218203/90b01ba97b6bc3ab8e" target="_blank"><img src="/file/464001058/109a6/XLMi7E5_IvY.218203/90b01ba97b6bc3ab8e" title="" alt="Color parameters guide" srcset="/file/464001058/109a6/XLMi7E5_IvY.218203/90b01ba97b6bc3ab8e , 2x" /></a>
<div>
<a href="/file/464001695/11185/DAwyUjA7LNA.215601/26f4c8ebf862ae860d" target="_blank"><img src="/file/464001695/11185/DAwyUjA7LNA.215601/26f4c8ebf862ae860d" title="WebViewColors explained" class="dev_page_image" /></a>
</div>
<h4><a class="anchor" name="backbutton" href="#backbutton"><i class="anchor-icon"></i></a>BackButton</h4>
<p><sup><mark>NEW</mark></sup> This object controls the <strong>back</strong> button, which can be displayed in the header of the Web App in the Telegram interface.</p>
<table class="table">
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>isVisible</td>
<td>Boolean</td>
<td>Shows whether the button is visible. Set to <em>false</em> by default.</td>
</tr>
<tr>
<td>onClick(callback)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that sets the button press event handler. An alias for <code>Telegram.WebApp.onEvent(&#39;backButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>offClick(callback)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method that removes the button press event handler. An alias for <code>Telegram.WebApp.offEvent(&#39;backButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>show()</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method to make the button active and visible.</td>
</tr>
<tr>
<td>hide()</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method to hide the button.</td>
</tr>
</tbody>
</table>
<p>All these methods return the BackButton object so they can be chained.</p>
<h4><a class="anchor" name="mainbutton" href="#mainbutton"><i class="anchor-icon"></i></a>MainButton</h4>
<p>This object controls the main button, which is displayed at the bottom of the Web App in the Telegram interface.</p>
<table class="table">
@ -326,6 +439,11 @@
<td>A method that sets the button press event handler. An alias for <code>Telegram.WebApp.onEvent(&#39;mainButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>offClick(callback) <sup><mark>NEW</mark></sup></td>
<td>Function</td>
<td>A method that removes the button press event handler. An alias for <code>Telegram.WebApp.offEvent(&#39;mainButtonClicked&#39;, callback)</code></td>
</tr>
<tr>
<td>show()</td>
<td>Function</td>
<td>A method to make the button visible.<br><em>Note that opening the Web App from the <a href="#launching-web-apps-from-the-attachment-menu">attachment menu</a> hides the main button until the user interacts with the Web App interface.</em></td>
@ -363,6 +481,35 @@
</tbody>
</table>
<p>All these methods return the MainButton object so they can be chained.</p>
<h4><a class="anchor" name="hapticfeedback" href="#hapticfeedback"><i class="anchor-icon"></i></a>HapticFeedback</h4>
<p><sup><mark>NEW</mark></sup> This object controls haptic feedback.</p>
<table class="table">
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>impactOccurred(style)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method tells that an impact occurred. The Telegram app may play the appropriate haptics based on style value passed. Style can be one of these values:<br>- <em>light</em>, indicates a collision between small or lightweight UI objects,<br>- <em>medium</em>, indicates a collision between medium-sized or medium-weight UI objects,<br>- <em>heavy</em>, indicates a collision between large or heavyweight UI objects,<br>- <em>rigid</em>, indicates a collision between hard or inflexible UI objects,<br>- <em>soft</em>, indicates a collision between soft or flexible UI objects.</td>
</tr>
<tr>
<td>notificationOccurred(type)</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method tells that a task or action has succeeded, failed, or produced a warning. The Telegram app may play the appropriate haptics based on type value passed. Type can be one of these values:<br>- <em>error</em>, indicates that a task or action has failed,<br>- <em>success</em>, indicates that a task or action has completed successfully,<br>- <em>warning</em>, indicates that a task or action produced a warning.</td>
</tr>
<tr>
<td>selectionChanged()</td>
<td>Function</td>
<td><mark>Bot API 6.1+</mark> A method tells that the user has changed a selection. The Telegram app may play the appropriate haptics.<br><br><em>Do not use this feedback when the user makes or confirms a selection; use it only when the selection changes.</em></td>
</tr>
</tbody>
</table>
<p>All these methods return the HapticFeedback object so they can be chained.</p>
<h4><a class="anchor" name="webappinitdata" href="#webappinitdata"><i class="anchor-icon"></i></a>WebAppInitData</h4>
<p>This object contains data that is transferred to the Web App when it is opened. It is empty if the Web App was launched from a <a href="#keyboard-button-web-apps">keyboard button</a>.</p>
<table class="table">
@ -387,7 +534,12 @@
<tr>
<td>receiver</td>
<td><a href="#webappuser">WebAppUser</a></td>
<td><em>Optional.</em> An object containing data about the chat partner of the current user in the chat where the bot was launched via the attachment menu. Returned only for Web Apps launched via the attachment menu.</td>
<td><em>Optional.</em> An object containing data about the chat partner of the current user in the chat where the bot was launched via the attachment menu. Returned only for private chats and only for Web Apps launched via the attachment menu.</td>
</tr>
<tr>
<td>chat <sup><mark>NEW</mark></sup></td>
<td><a href="#webappchat">WebAppChat</a></td>
<td><em>Optional.</em> An object containing data about the chat where the bot was launched via the attachment menu. Returned for supergroups, channels and group chats only for Web Apps launched via the attachment menu.</td>
</tr>
<tr>
<td>start_param</td>
@ -395,6 +547,11 @@
<td><em>Optional.</em> The value of the <em>startattach</em> parameter, passed <a href="#adding-bots-to-the-attachment-menu">via link</a>. Only returned for Web Apps when launched from the attachment menu via link.<br><br>The value of the <code>start_param</code> parameter will also be passed in the GET-parameter <code>tgWebAppStartParam</code>, so the Web App can load the correct interface right away.</td>
</tr>
<tr>
<td>can_send_after <sup><mark>NEW</mark></sup></td>
<td>Integer</td>
<td><em>Optional.</em> Time in seconds, after which a message can be sent via the <a href="/bots/api#answerwebappquery">answerWebAppQuery</a> method.</td>
</tr>
<tr>
<td>auth_date</td>
<td>Integer</td>
<td>Unix time when the form was opened.</td>
@ -454,6 +611,44 @@
</tr>
</tbody>
</table>
<h4><a class="anchor" name="webappchat" href="#webappchat"><i class="anchor-icon"></i></a>WebAppChat</h4>
<p><sup><mark>NEW</mark></sup> This object represents a chat.</p>
<table class="table">
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>Integer</td>
<td>Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.</td>
</tr>
<tr>
<td>type</td>
<td>String</td>
<td>Type of chat, can be either “group”, “supergroup” or “channel”</td>
</tr>
<tr>
<td>title</td>
<td>String</td>
<td>Title of the chat</td>
</tr>
<tr>
<td>username</td>
<td>String</td>
<td><em>Optional</em>. Username of the chat</td>
</tr>
<tr>
<td>photo_url</td>
<td>String</td>
<td><em>Optional</em>. URL of the chats photo. The photo can be in .jpeg or .svg formats. Only returned for Web Apps launched from the attachment menu.</td>
</tr>
</tbody>
</table>
<h4><a class="anchor" name="validating-data-received-via-the-web-app" href="#validating-data-received-via-the-web-app"><i class="anchor-icon"></i></a>Validating data received via the Web App</h4>
<p>To validate data received via the Web App, one should send the data from the <em>Telegram.WebApp.initData</em> field to the bot&#39;s backend. The data is a query string, which is composed of a series of field-value pairs.</p>
<p>You can verify the integrity of the data received by comparing the received <em>hash</em> parameter with the hexadecimal representation of the <a href="https://en.wikipedia.org/wiki/Hash-based_message_authentication_code">HMAC-SHA-256</a> signature of the <strong>data-check-string</strong> with the secret key, which is the <a href="https://en.wikipedia.org/wiki/Hash-based_message_authentication_code">HMAC-SHA-256</a> signature of the <a href="/bots#creating-a-new-bot">bot&#39;s token</a> with the constant string <code>WebAppData</code> used as a key.</p>
@ -488,6 +683,18 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
<td><code>mainButtonClicked</code></td>
<td>Occurs when the <a href="#mainbutton">main button</a> is pressed.<br><em>eventHandler</em> receives no parameters.</td>
</tr>
<tr>
<td><code>backButtonClicked</code> <sup><mark>NEW</mark></sup></td>
<td><mark>Bot API 6.1+</mark> Occurrs when the <a href="#backbutton">back button</a> is pressed.<br><em>eventHandler</em> receives no parameters.</td>
</tr>
<tr>
<td><code>settingsButtonClicked</code> <sup><mark>NEW</mark></sup></td>
<td><mark>Bot API 6.1+</mark> Occurrs when the Settings item in context menu is pressed.<br><em>eventHandler</em> receives no parameters.</td>
</tr>
<tr>
<td><code>invoiceClosed</code> <sup><mark>NEW</mark></sup></td>
<td><mark>Bot API 6.1+</mark> Occurrs when the opened invoice is closed.<br><em>eventHandler</em> receives an object with the two fields: <em>url</em> invoice link provided and <em>status</em> one of the invoice statuses:<br>- <strong>paid</strong> invoice was paid successfully,<br>- <strong>cancelled</strong> user closed this invoice without paying,<br>- <strong>failed</strong> user tried to pay, but the payment was failed,<br>- <strong>pending</strong> the payment is still processing. The bot will receive a service message about a <a href="https://core.telegram.org/bots/api#successfulpayment">successful payment</a> when the payment is successfully paid.</td>
</tr>
</tbody>
</table>
<h4><a class="anchor" name="adding-bots-to-the-attachment-menu" href="#adding-bots-to-the-attachment-menu"><i class="anchor-icon"></i></a>Adding Bots to the Attachment Menu</h4>
@ -501,6 +708,9 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
<p>The following link formats are also supported:</p>
<p><code>https://t.me/username?attach=botusername</code><br><code>https://t.me/username?attach=botusername&amp;startattach=command</code><br><code>https://t.me/+1234567890?attach=botusername</code><br><code>https://t.me/+1234567890?attach=botusername&amp;startattach=command</code></p>
<p>These links open the Web App in the attachment menu in the chat with a specific user. If the bot wasn&#39;t already added to the attachment menu, the user will be prompted to do so. If a non-empty <em>startattach</em> parameter was included in the link, it will be passed to the Web App in the <em>start_param</em> field and in the GET parameter <em>tgWebAppStartParam</em>.</p>
<p><mark>Bot API 6.1+</mark> supports a new link format:</p>
<p><code>https://t.me/botusername?startattach&amp;choose=users+bots</code><br><code>https://t.me/botusername?startattach=command&amp;choose=groups+channels</code></p>
<p>Opening such a link prompts the user to choose a specific chat and opens the attachment menu in that chat. If the bot wasn&#39;t already added to the attachment menu, the user will be prompted to do so. You can specify which types of chats the user will be able to choose from. It can be one or more of the following types: <em>users</em>, <em>bots</em>, <em>groups</em>, <em>channels</em> separated by a <code>+</code> sign. If a non-empty <em>startattach</em> parameter was included in the link, it will be passed to the Web App in the <em>start_param</em> field and in the GET parameter <em>tgWebAppStartParam</em>.</p>
<h3><a class="anchor" name="testing-web-apps" href="#testing-web-apps"><i class="anchor-icon"></i></a>Testing Web Apps</h3>
<h4><a class="anchor" name="using-bots-in-the-test-environment" href="#using-bots-in-the-test-environment"><i class="anchor-icon"></i></a>Using bots in the test environment</h4>
<p>To log in to the test environment, use either of the following:</p>
@ -511,10 +721,31 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
</ul>
<p>The test environment is completely separate from the main environment, so you will need to create a <strong>new user account</strong> and a <strong>new bot</strong> with @BotFather.</p>
<p>After receiving your bot token, you can send requests to the Bot API in this format: </p>
<p><code>https://api.telegram.org/bot&lt;token&gt;/test/METHOD_NAME</code></p>
<pre><code>https://api.telegram.org/bot&lt;token&gt;/test/METHOD_NAME</code></pre>
<blockquote>
<p><strong>Note:</strong> When working with the test environment, you may use HTTP links without TLS to test your Web App.</p>
</blockquote>
<h4><a class="anchor" name="debug-mode-for-web-apps" href="#debug-mode-for-web-apps"><i class="anchor-icon"></i></a>Debug Mode for Web Apps</h4>
<p>Use these tools to find app-specific issues in your Web App:</p>
<p><strong>Android</strong></p>
<ul>
<li><a href="https://developer.chrome.com/docs/devtools/remote-debugging/">Enable USB-Debugging</a> on your device.</li>
<li>In Telegram Settings, scroll all the way down, press and hold on the <strong>version number</strong> two times.</li>
<li>Choose <em>Enable WebView Debug</em> in the Debug Settings.</li>
<li>Connect your phone to your computer and open <code>chrome://inspect/#devices</code> in Chrome you will see your Web App there when you launch it on your phone.</li>
</ul>
<p><strong>Telegram Desktop on Windows and Linux</strong></p>
<ul>
<li>Download and launch the <a href="https://desktop.telegram.org/changelog#beta-version">Beta Version</a> of Telegram Desktop on <strong>Windows</strong> or <strong>Linux</strong> (not supported on Telegram Desktop for macOS yet).</li>
<li>Go to <em>Settings &gt; Advanced &gt; Experimental settings &gt; Enable webview inspection</em>.</li>
<li>Right click in the WebView and choose <em>Inspect</em>.</li>
</ul>
<p><strong>Telegram macOS</strong></p>
<ul>
<li>Download and launch the <a href="https://telegram.org/dl/macos/beta">Beta Version</a> of Telegram macOS.</li>
<li>Quickly click 5 times on the Settings icon to open the debug menu and enable “Debug Web Apps”.</li>
<li>Right click in the web app and choose <em>Inspect Element</em>.</li>
</ul>
</div>
</div>