From de3960fa5ab3220a21d85f0df6dc85e1f9576f06 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 1 Aug 2024 18:40:00 +0000 Subject: [PATCH] Update content of files --- .../web/corefork.telegram.org/api/config.html | 2 +- .../web/corefork.telegram.org/api/layers.html | 2 +- .../corefork.telegram.org/bots/webapps.html | 361 +++++++++--------- 3 files changed, 182 insertions(+), 183 deletions(-) diff --git a/data/web/corefork.telegram.org/api/config.html b/data/web/corefork.telegram.org/api/config.html index ba7fdee665..0dc3a37df0 100644 --- a/data/web/corefork.telegram.org/api/config.html +++ b/data/web/corefork.telegram.org/api/config.html @@ -693,7 +693,7 @@ A full list of these parameters can be seen in the - Suggests the user to subscribe to Telegram Premium (with annual payments)
  • "PREMIUM_UPGRADE" - Suggests the user to upgrade their existing Premium subscription from monthly payments to annual payments
  • "PREMIUM_RESTORE" - Suggests the user to restore a recently expired Premium subscription
  • -
  • "PREMIUM_CHRISTMAS" - Suggests the user to gift Telegram Premium subscription to friends for Christmas.
  • +
  • "PREMIUM_CHRISTMAS" - Suggests the user to gift Telegram Premium subscriptions to friends for Christmas.
  • "PREMIUM_GRACE" - Suggests the user to extend their expiring Telegram Premium subscription
  • "BIRTHDAY_SETUP" - Suggests the user to set a birthday ».
  • diff --git a/data/web/corefork.telegram.org/api/layers.html b/data/web/corefork.telegram.org/api/layers.html index 6d26b6dbaa..041deb4a00 100644 --- a/data/web/corefork.telegram.org/api/layers.html +++ b/data/web/corefork.telegram.org/api/layers.html @@ -71,7 +71,7 @@

    The following new suggestions » were added:

    This layer introduces fact-checks », Telegram Stars and collapsible message quotes ».

    diff --git a/data/web/corefork.telegram.org/bots/webapps.html b/data/web/corefork.telegram.org/bots/webapps.html index 312f609a17..deaaa9c69c 100644 --- a/data/web/corefork.telegram.org/bots/webapps.html +++ b/data/web/corefork.telegram.org/bots/webapps.html @@ -49,26 +49,27 @@
    +
    +

    To see a Mini App in action, try our sample @DurgerKingBot.


    -

    Recent changes

    -

    March 31, 2024

    +

    Recent changes

    +

    March 31, 2024

    Bot API 7.2

    -

    December 29, 2023

    +

    December 29, 2023

    Bot API 7.0

    -

    September 22, 2023

    +

    September 22, 2023

    Bot API 6.9

    -

    April 21, 2023

    +

    April 21, 2023

    Bot API 6.7

    -

    December 30, 2022

    +

    December 30, 2022

    Bot API 6.4

    -

    August 12, 2022

    +

    August 12, 2022

    Bot API 6.2

    -

    June 20, 2022

    +

    June 20, 2022

    Bot API 6.1


    -

    Designing Mini Apps

    -

    Color Schemes

    -

    Mini Apps always receive data about the user's current color theme in real time, so you can adjust the appearance of your interfaces to match it. For example, when users switch between Day and Night modes or use various custom themes.

    +

    Designing Mini Apps

    +

    Color Schemes

    +

    Mini Apps always receive data about the user's current color theme in real time, so you can adjust the appearance of your interfaces to match it. For example, when users switch between Day and Night modes or use various custom themes.

    +
    +

    Jump to technical information

    -

    Design Guidelines

    +

    Design Guidelines

    Telegram apps are known for being snappy, smooth and following a consistent cross-platform design. Your Mini App should ideally reflect these principles.


    -

    Implementing Mini Apps

    -

    Telegram currently supports six different ways of launching Mini Apps: from a keyboard button, from an inline button, from the bot menu button, via inline mode, from a direct link – and even from the attachment menu.

    +

    Implementing Mini Apps

    +

    Telegram currently supports six different ways of launching Mini Apps: from a keyboard button, from an inline button, from the bot menu button, via inline mode, from a direct link – and even from the attachment menu.

    - Types of buttons + Types of buttons
    -

    Keyboard Button Mini Apps

    + +

    Keyboard Button Mini Apps

    TL;DR: Mini Apps launched from a web_app type keyboard button can send data back to the bot in a service message using Telegram.WebApp.sendData. This makes it possible for the bot to produce a response without communicating with any external servers.

    @@ -143,84 +146,84 @@

    To transmit data from the user back to the bot, the Mini App can call the Telegram.WebApp.sendData method. Data will be transmitted to the bot as a String in a service message. The bot can continue communicating with the user after receiving it.

    Good for:

    -

    Inline Button Mini Apps

    +

    Inline Button Mini Apps

    TL;DR: For more interactive Mini Apps like @DurgerKingBot, use a web_app type Inline KeyboardButton, which gets basic user information and can be used to send a message on behalf of the user to the chat with the bot.

    If receiving text data alone is insufficient or you need a more advanced and personalized interface, you can open a Mini App using a web_app type Inline KeyboardButton.

    -

    From the button, a Mini App will open with the URL specified in the button. In addition to the user's theme settings, it will receive basic user information (ID, name, username, language_code) and a unique identifier for the session, query_id, which allows messages on behalf of the user to be sent back to the bot.

    +

    From the button, a Mini App will open with the URL specified in the button. In addition to the user's theme settings, it will receive basic user information (ID, name, username, language_code) and a unique identifier for the session, query_id, which allows messages on behalf of the user to be sent back to the bot.

    The bot can call the Bot API method answerWebAppQuery to send an inline message from the user back to the bot and close the Mini App. After receiving the message, the bot can continue communicating with the user.

    Good for:

    -

    Launching Mini Apps from the Menu Button

    +

    Launching Mini Apps from the Menu Button

    TL;DR: Mini Apps can be launched from a customized menu button. This simply offers a quicker way to access the app and is otherwise identical to launching a mini app from an inline button.

    By default, chats with bots always show a convenient menu button that provides quick access to all listed commands. With Bot API 6.0, this button can be used to launch a Mini App instead.

    - +
    +

    To configure the menu button, you must specify the text it should show and the Mini App URL. There are two ways to set these parameters:

    Apart from this, Mini Apps opened via the menu button work in the exact same way as when using inline buttons.

    @DurgerKingBot allows launching its Mini App both from an inline button and from the menu button.

    -

    Inline Mode Mini Apps

    +

    Inline Mode Mini Apps

    TL;DR: Mini Apps launched via web_app type InlineQueryResultsButton can be used anywhere in inline mode. Users can create content in a web interface and then seamlessly send it to the current chat via inline mode.

    -

    You can use the button parameter in the answerInlineQuery method to display a special 'Switch to Mini App' button either above or in place of the inline results. This button will open a Mini App from the specified URL. Once done, you can call the Telegram.WebApp.switchInlineQuery method to send the user back to inline mode.

    -

    Inline Mini Apps have no access to the chat – they can't read messages or send new ones on behalf of the user. To send messages, the user must be redirected to inline mode and actively pick a result.

    +

    You can use the button parameter in the answerInlineQuery method to display a special 'Switch to Mini App' button either above or in place of the inline results. This button will open a Mini App from the specified URL. Once done, you can call the Telegram.WebApp.switchInlineQuery method to send the user back to inline mode.

    +

    Inline Mini Apps have no access to the chat – they can't read messages or send new ones on behalf of the user. To send messages, the user must be redirected to inline mode and actively pick a result.

    Good for:

    -

    Direct Link Mini Apps

    +

    Direct Link Mini Apps

    TL;DR: Mini App Bots can be launched from a direct link in any chat. They support a startapp parameter and are aware of the current chat context.

    You can use direct links to open a Mini App directly in the current chat. If a non-empty startapp parameter is included in the link, it will be passed to the Mini App in the start_param field and in the GET parameter tgWebAppStartParam.

    In this mode, Mini Apps can use the chat_type and chat_instance parameters to keep track of the current chat context. This introduces support for concurrent and shared usage by multiple chat members – to create live whiteboards, group orders, multiplayer games and similar apps.

    -

    Mini Apps opened from a direct link have no access to the chat – they can't read messages or send new ones on behalf of the user. To send messages, the user must be redirected to inline mode and actively pick a result.

    +

    Mini Apps opened from a direct link have no access to the chat – they can't read messages or send new ones on behalf of the user. To send messages, the user must be redirected to inline mode and actively pick a result.

    Examples

    -

    https://t.me/botusername/appname -https://t.me/botusername/appname?startapp=command

    +

    https://t.me/botusername/appname
    https://t.me/botusername/appname?startapp=command

    Good for:

    -

    Launching Mini Apps from the Attachment Menu

    +

    Launching Mini Apps from the Attachment Menu

    -

    TL;DR: Mini App Bots can request to be added directly to a user's attachment menu, allowing them to be quickly launched from any chat. To try this mode, open this attachment menu link for @DurgerKingBot, then use the Attach menu in any type of chat.

    +

    TL;DR: Mini App Bots can request to be added directly to a user's attachment menu, allowing them to be quickly launched from any chat. To try this mode, open this attachment menu link for @DurgerKingBot, then use the Attach menu in any type of chat.

    -

    Mini App Bots can request to be added directly to a user's attachment menu, allowing them to be quickly launched from any type of chat. You can configure in which types of chats your mini app can be started from the attachment menu (private, groups, supergroups or channels).

    -

    Attachment menu integration is currently only available for major advertisers on the Telegram Ad Platform. However, all bots can use it in the test server environment.

    -

    To enable this feature for your bot, open @BotFather from an account on the test server and send the /setattach command – or go to Bot Settings > Configure Attachment Menu. Then specify the URL that will be opened to launch the bot's Mini App via its icon in the attachment menu.

    -

    You can add a 'Settings' item to the context menu of your Mini App using @BotFather. When users select this option from the menu, your bot will receive a settingsButtonClicked event.

    -

    In addition to the user's theme settings, the bot will receive basic user information (ID, name, username, language_code, photo), as well as public info about the chat partner (ID, name, username, photo) or the chat info (ID, type, title, username, photo) and a unique identifier for the web view session query_id, which allows messages of any type to be sent to the chat on behalf of the user that opened the bot.

    +

    Mini App Bots can request to be added directly to a user's attachment menu, allowing them to be quickly launched from any type of chat. You can configure in which types of chats your mini app can be started from the attachment menu (private, groups, supergroups or channels).

    +

    Attachment menu integration is currently only available for major advertisers on the Telegram Ad Platform. However, all bots can use it in the test server environment.

    +

    To enable this feature for your bot, open @BotFather from an account on the test server and send the /setattach command – or go to Bot Settings > Configure Attachment Menu. Then specify the URL that will be opened to launch the bot's Mini App via its icon in the attachment menu.

    +

    You can add a 'Settings' item to the context menu of your Mini App using @BotFather. When users select this option from the menu, your bot will receive a settingsButtonClicked event.

    +

    In addition to the user's theme settings, the bot will receive basic user information (ID, name, username, language_code, photo), as well as public info about the chat partner (ID, name, username, photo) or the chat info (ID, type, title, username, photo) and a unique identifier for the web view session query_id, which allows messages of any type to be sent to the chat on behalf of the user that opened the bot.

    The bot can call the Bot API method answerWebAppQuery, which sends an inline message from the user via the bot to the chat where it was launched and closes the Mini App.

    You can read more about adding bots to the attachment menu here.


    -

    Initializing Mini Apps

    +

    Initializing Mini Apps

    To connect your Mini App to the Telegram client, place the script telegram-web-app.js in the <head> tag before any other scripts, using this code:

    -
    <script src="https://telegram.org/js/telegram-web-app.js"></script>
    +
    <script src="https://telegram.org/js/telegram-web-app.js"></script>

    Once the script is connected, a window.Telegram.WebApp object will become available with the following fields:

    @@ -234,27 +237,27 @@ - + - + - + - + - + @@ -269,12 +272,12 @@ - + - + @@ -317,34 +320,34 @@ - + - + - + - + - + - + @@ -364,67 +367,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -438,8 +441,8 @@
    initData StringA string with raw data transferred to the Mini App, convenient for validating data.
    WARNING: Validate data from this field before using it on the bot's server.
    A string with raw data transferred to the Mini App, convenient for validating data.
    WARNING: Validate data from this field before using it on the bot's server.
    initDataUnsafe WebAppInitDataAn object with input data transferred to the Mini App.
    WARNING: Data from this field should not be trusted. You should only use data from initData on the bot's server and only after it has been validated.
    An object with input data transferred to the Mini App.
    WARNING: Data from this field should not be trusted. You should only use data from initData on the bot's server and only after it has been validated.
    version StringThe version of the Bot API available in the user's Telegram app.The version of the Bot API available in the user's Telegram app.
    platform StringThe name of the platform of the user's Telegram app.The name of the platform of the user's Telegram app.
    colorScheme StringThe color scheme currently used in the Telegram app. Either “light” or “dark”.
    Also available as the CSS variable var(--tg-color-scheme).
    The color scheme currently used in the Telegram app. Either “light” or “dark”.
    Also available as the CSS variable var(--tg-color-scheme).
    themeParams
    viewportHeight FloatThe current height of the visible area of the Mini App. Also available in CSS as the variable var(--tg-viewport-height).

    The application can display just the top part of the Mini App, with its lower part remaining outside the screen area. From this position, the user can "pull" the Mini App to its maximum height, while the bot can do the same by calling the expand() method. As the position of the Mini App changes, the current height value of the visible area will be updated in real time.

    Please note that the refresh rate of this value is not sufficient to smoothly follow the lower border of the window. It should not be used to pin interface elements to the bottom of the visible area. It's more appropriate to use the value of the viewportStableHeight field for this purpose.
    The current height of the visible area of the Mini App. Also available in CSS as the variable var(--tg-viewport-height).

    The application can display just the top part of the Mini App, with its lower part remaining outside the screen area. From this position, the user can “pull” the Mini App to its maximum height, while the bot can do the same by calling the expand() method. As the position of the Mini App changes, the current height value of the visible area will be updated in real time.

    Please note that the refresh rate of this value is not sufficient to smoothly follow the lower border of the window. It should not be used to pin interface elements to the bottom of the visible area. It's more appropriate to use the value of the viewportStableHeight field for this purpose.
    viewportStableHeight FloatThe height of the visible area of the Mini App in its last stable state. Also available in CSS as a variable var(--tg-viewport-stable-height).

    The application can display just the top part of the Mini App, with its lower part remaining outside the screen area. From this position, the user can "pull" the Mini App to its maximum height, while the bot can do the same by calling the expand() method. Unlike the value of viewportHeight, the value of viewportStableHeight does not change as the position of the Mini App changes with user gestures or during animations. The value of viewportStableHeight will be updated after all gestures and animations are completed and the Mini App reaches its final size.

    Note the event viewportChanged with the passed parameter isStateStable=true, which will allow you to track when the stable state of the height of the visible area changes.
    The height of the visible area of the Mini App in its last stable state. Also available in CSS as a variable var(--tg-viewport-stable-height).

    The application can display just the top part of the Mini App, with its lower part remaining outside the screen area. From this position, the user can “pull” the Mini App to its maximum height, while the bot can do the same by calling the expand() method. Unlike the value of viewportHeight, the value of viewportStableHeight does not change as the position of the Mini App changes with user gestures or during animations. The value of viewportStableHeight will be updated after all gestures and animations are completed and the Mini App reaches its final size.

    Note the event viewportChanged with the passed parameter isStateStable=true, which will allow you to track when the stable state of the height of the visible area changes.
    headerColorAn object for controlling cloud storage.
    BiometricManager ^==NEW==^BiometricManager NEW BiometricManager An object for controlling biometrics on the device.
    isVersionAtLeast(version) FunctionReturns true if the user's app supports a version of the Bot API that is equal to or higher than the version passed as the parameter.Returns true if the user's app supports a version of the Bot API that is equal to or higher than the version passed as the parameter.
    setHeaderColor(color) Function==Bot API 6.1+== A method that sets the app header color in the #RRGGBB format. You can also use keywords bg_color and secondary_bg_color.

    Up to ==Bot API 6.9== You can only pass Telegram.WebApp.themeParams.bg_color or Telegram.WebApp.themeParams.secondary_bg_color as a color or bg_color, secondary_bg_color keywords.
    Bot API 6.1+ A method that sets the app header color in the #RRGGBB format. You can also use keywords bg_color and secondary_bg_color.

    Up to Bot API 6.9 You can only pass Telegram.WebApp.themeParams.bg_color or Telegram.WebApp.themeParams.secondary_bg_color as a color or bg_color, secondary_bg_color keywords.
    setBackgroundColor(color) Function==Bot API 6.1+== A method that sets the app background color in the #RRGGBB format. You can also use keywords bg_color and secondary_bg_color.Bot API 6.1+ A method that sets the app background color in the #RRGGBB format. You can also use keywords bg_color and secondary_bg_color.
    enableClosingConfirmation() Function==Bot API 6.2+== A method that enables a confirmation dialog while the user is trying to close the Mini App.Bot API 6.2+ A method that enables a confirmation dialog while the user is trying to close the Mini App.
    disableClosingConfirmation() Function==Bot API 6.2+== A method that disables the confirmation dialog while the user is trying to close the Mini App.Bot API 6.2+ A method that disables the confirmation dialog while the user is trying to close the Mini App.
    onEvent(eventType, eventHandler)
    switchInlineQuery(query[, choose_chat_types]) Function==Bot API 6.7+== A method that inserts the bot's username and the specified inline query in the current chat's input field. Query may be empty, in which case only the bot's username will be inserted. If an optional choose_chat_types parameter was passed, the client prompts the user to choose a specific chat, then opens that chat and inserts the bot's username and the specified inline query in the input field. 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: users, bots, groups, channels.Bot API 6.7+ A method that inserts the bot's username and the specified inline query in the current chat's input field. Query may be empty, in which case only the bot's username will be inserted. If an optional choose_chat_types parameter was passed, the client prompts the user to choose a specific chat, then opens that chat and inserts the bot's username and the specified inline query in the input field. 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: users, bots, groups, channels.
    openLink(url[, options]) FunctionA method that opens a link in an external browser. The Mini App will not be closed.
    ==Bot API 6.4+== If the optional options parameter is passed with the field try_instant_view=true, the link will be opened in Instant View mode if possible.

    Note that this method can be called only in response to user interaction with the Mini App interface (e.g. a click inside the Mini App or on the main button)
    A method that opens a link in an external browser. The Mini App will not be closed.
    Bot API 6.4+ If the optional options parameter is passed with the field try_instant_view=true, the link will be opened in Instant View mode if possible.

    Note that this method can be called only in response to user interaction with the Mini App interface (e.g. a click inside the Mini App or on the main button)
    openTelegramLink(url) FunctionA method that opens a telegram link inside the Telegram app. The Mini App will not be closed after this method is called.

    Up to ==Bot API 7.0== The Mini App will be closed after this method is called.
    A method that opens a telegram link inside the Telegram app. The Mini App will not be closed after this method is called.

    Up to Bot API 7.0 The Mini App will be closed after this method is called.
    openInvoice(url[, callback]) Function==Bot API 6.1+== A method that opens an invoice using the link url. The Mini App will receive the event invoiceClosed when the invoice is closed. If an optional callback parameter was passed, the callback function will be called and the invoice status will be passed as the first argument.Bot API 6.1+ A method that opens an invoice using the link url. The Mini App will receive the event invoiceClosed when the invoice is closed. If an optional callback parameter was passed, the callback function will be called and the invoice status will be passed as the first argument.
    showPopup(params[, callback]) Function==Bot API 6.2+== A method that shows a native popup described by the params argument of the type PopupParams. The Mini App will receive the event popupClosed when the popup is closed. If an optional callback parameter was passed, the callback function will be called and the field id of the pressed button will be passed as the first argument.Bot API 6.2+ A method that shows a native popup described by the params argument of the type PopupParams. The Mini App will receive the event popupClosed when the popup is closed. If an optional callback parameter was passed, the callback function will be called and the field id of the pressed button will be passed as the first argument.
    showAlert(message[, callback]) Function==Bot API 6.2+== A method that shows message in a simple alert with a 'Close' button. If an optional callback parameter was passed, the callback function will be called when the popup is closed.Bot API 6.2+ A method that shows message in a simple alert with a 'Close' button. If an optional callback parameter was passed, the callback function will be called when the popup is closed.
    showConfirm(message[, callback]) Function==Bot API 6.2+== A method that shows message in a simple confirmation window with 'OK' and 'Cancel' buttons. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user pressed the 'OK' button.Bot API 6.2+ A method that shows message in a simple confirmation window with 'OK' and 'Cancel' buttons. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user pressed the 'OK' button.
    showScanQrPopup(params[, callback]) Function==Bot API 6.4+== A method that shows a native popup for scanning a QR code described by the params argument of the type ScanQrPopupParams. The Mini App will receive the event qrTextReceived every time the scanner catches a code with text data. If an optional callback parameter was passed, the callback function will be called and the text from the QR code will be passed as the first argument. Returning true inside this callback function causes the popup to be closed.Bot API 6.4+ A method that shows a native popup for scanning a QR code described by the params argument of the type ScanQrPopupParams. The Mini App will receive the event qrTextReceived every time the scanner catches a code with text data. If an optional callback parameter was passed, the callback function will be called and the text from the QR code will be passed as the first argument. Returning true inside this callback function causes the popup to be closed.
    closeScanQrPopup() Function==Bot API 6.4+== A method that closes the native popup for scanning a QR code opened with the showScanQrPopup method. Run it if you received valid data in the event qrTextReceived.Bot API 6.4+ A method that closes the native popup for scanning a QR code opened with the showScanQrPopup method. Run it if you received valid data in the event qrTextReceived.
    readTextFromClipboard([callback]) Function==Bot API 6.4+== A method that requests text from the clipboard. The Mini App will receive the event clipboardTextReceived. If an optional callback parameter was passed, the callback function will be called and the text from the clipboard will be passed as the first argument.

    Note: this method can be called only for Mini Apps launched from the attachment menu and only in response to a user interaction with the Mini App interface (e.g. a click inside the Mini App or on the main button).
    Bot API 6.4+ A method that requests text from the clipboard. The Mini App will receive the event clipboardTextReceived. If an optional callback parameter was passed, the callback function will be called and the text from the clipboard will be passed as the first argument.

    Note: this method can be called only for Mini Apps launched from the attachment menu and only in response to a user interaction with the Mini App interface (e.g. a click inside the Mini App or on the main button).
    requestWriteAccess([callback]) Function==Bot API 6.9+== A method that shows a native popup requesting permission for the bot to send messages to the user. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user granted this access.Bot API 6.9+ A method that shows a native popup requesting permission for the bot to send messages to the user. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user granted this access.
    requestContact([callback]) Function==Bot API 6.9+== A method that shows a native popup prompting the user for their phone number. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user shared its phone number.Bot API 6.9+ A method that shows a native popup prompting the user for their phone number. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user shared its phone number.
    ready() FunctionA method that informs the Telegram app that the Mini App is ready to be displayed.
    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 Mini App is shown.
    If the method is not called, the placeholder will be hidden only when the page is fully loaded.
    A method that informs the Telegram app that the Mini App is ready to be displayed.
    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 Mini App is shown.
    If the method is not called, the placeholder will be hidden only when the page is fully loaded.
    expand()
    -

    ThemeParams

    -

    Mini Apps can adjust the appearance of the interface to match the Telegram user's app in real time. This object contains the user's current theme settings:

    +

    ThemeParams

    +

    Mini Apps can adjust the appearance of the interface to match the Telegram user's app in real time. This object contains the user's current theme settings:

    @@ -452,74 +455,75 @@ - + - + - + - + - + - + - + - + - + - + - + - + - +
    bg_color StringOptional. Background color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-bg-color).
    Optional. Background color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-bg-color).
    text_color StringOptional. Main text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-text-color).
    Optional. Main text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-text-color).
    hint_color StringOptional. Hint text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-hint-color).
    Optional. Hint text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-hint-color).
    link_color StringOptional. Link color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-link-color).
    Optional. Link color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-link-color).
    button_color StringOptional. Button color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-button-color).
    Optional. Button color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-button-color).
    button_text_color StringOptional. Button text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-button-text-color).
    Optional. Button text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-button-text-color).
    secondary_bg_color StringOptional. ==Bot API 6.1+== Secondary background color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-secondary-bg-color).
    Optional. Bot API 6.1+ Secondary background color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-secondary-bg-color).
    header_bg_color StringOptional. ==Bot API 7.0+== Header background color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-header-bg-color).
    Optional. Bot API 7.0+ Header background color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-header-bg-color).
    accent_text_color StringOptional. ==Bot API 7.0+== Accent text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-accent-text-color).
    Optional. Bot API 7.0+ Accent text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-accent-text-color).
    section_bg_color StringOptional. ==Bot API 7.0+== Background color for the section in the #RRGGBB format. It is recommended to use this in conjunction with secondary_bg_color.
    Also available as the CSS variable var(--tg-theme-section-bg-color).
    Optional. Bot API 7.0+ Background color for the section in the #RRGGBB format. It is recommended to use this in conjunction with secondary_bg_color.
    Also available as the CSS variable var(--tg-theme-section-bg-color).
    section_header_text_color StringOptional. ==Bot API 7.0+== Header text color for the section in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-section-header-text-color).
    Optional. Bot API 7.0+ Header text color for the section in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-section-header-text-color).
    subtitle_text_color StringOptional. ==Bot API 7.0+== Subtitle text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-subtitle-text-color).
    Optional. Bot API 7.0+ Subtitle text color in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-subtitle-text-color).
    destructive_text_color StringOptional. ==Bot API 7.0+== Text color for destructive actions in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-destructive-text-color).
    Optional. Bot API 7.0+ Text color for destructive actions in the #RRGGBB format.
    Also available as the CSS variable var(--tg-theme-destructive-text-color).
    - +
    -

    PopupParams

    + +

    PopupParams

    This object describes the native popup.

    @@ -543,11 +547,11 @@ - +
    buttons Array of PopupButtonOptional. List of buttons to be displayed in the popup, 1-3 buttons. Set to [{"type":"close"}] by default.Optional. List of buttons to be displayed in the popup, 1-3 buttons. Set to [{“type”:“close”}] by default.
    -

    ScanQrPopupParams

    +

    ScanQrPopupParams

    This object describes the native popup for scanning QR codes.

    @@ -561,11 +565,11 @@ - +
    text StringOptional. The text to be displayed under the 'Scan QR' heading, 0-64 characters.Optional. The text to be displayed under the 'Scan QR' heading, 0-64 characters.
    -

    PopupButton

    +

    PopupButton

    This object describes the native popup button.

    @@ -579,12 +583,12 @@ - + - + @@ -593,7 +597,7 @@
    id StringOptional. Identifier of the button, 0-64 characters. Set to empty string by default.
    If the button is pressed, its id is returned in the callback and the popupClosed event.
    Optional. Identifier of the button, 0-64 characters. Set to empty string by default.
    If the button is pressed, its id is returned in the callback and the popupClosed event.
    type StringOptional. Type of the button. Set to default by default.
    Can be one of these values:
    - default, a button with the default style,
    - ok, a button with the localized text "OK",
    - close, a button with the localized text "Close",
    - cancel, a button with the localized text "Cancel",
    - destructive, a button with a style that indicates a destructive action (e.g. "Remove", "Delete", etc.).
    Optional. Type of the button. Set to default by default.
    Can be one of these values:
    - default, a button with the default style,
    - ok, a button with the localized text “OK”,
    - close, a button with the localized text “Close”,
    - cancel, a button with the localized text “Cancel”,
    - destructive, a button with a style that indicates a destructive action (e.g. “Remove”, “Delete”, etc.).
    text
    -

    BackButton

    +

    BackButton

    This object controls the back button, which can be displayed in the header of the Mini App in the Telegram interface.

    @@ -612,27 +616,27 @@ - + - + - + - +
    onClick(callback) Function==Bot API 6.1+== A method that sets the button press event handler. An alias for Telegram.WebApp.onEvent('backButtonClicked', callback)Bot API 6.1+ A method that sets the button press event handler. An alias for Telegram.WebApp.onEvent('backButtonClicked', callback)
    offClick(callback) Function==Bot API 6.1+== A method that removes the button press event handler. An alias for Telegram.WebApp.offEvent('backButtonClicked', callback)Bot API 6.1+ A method that removes the button press event handler. An alias for Telegram.WebApp.offEvent('backButtonClicked', callback)
    show() Function==Bot API 6.1+== A method to make the button active and visible.Bot API 6.1+ A method to make the button active and visible.
    hide() Function==Bot API 6.1+== A method to hide the button.Bot API 6.1+ A method to hide the button.

    All these methods return the BackButton object so they can be chained.

    -

    MainButton

    +

    MainButton

    This object controls the main button, which is displayed at the bottom of the Mini App in the Telegram interface.

    @@ -681,17 +685,17 @@ - + - + - + @@ -711,7 +715,7 @@ - + @@ -721,12 +725,12 @@ - +
    onClick(callback) FunctionA method that sets the button press event handler. An alias for Telegram.WebApp.onEvent('mainButtonClicked', callback)A method that sets the button press event handler. An alias for Telegram.WebApp.onEvent('mainButtonClicked', callback)
    offClick(callback) FunctionA method that removes the button press event handler. An alias for Telegram.WebApp.offEvent('mainButtonClicked', callback)A method that removes the button press event handler. An alias for Telegram.WebApp.offEvent('mainButtonClicked', callback)
    show() FunctionA method to make the button visible.
    Note that opening the Mini App from the attachment menu hides the main button until the user interacts with the Mini App interface.
    A method to make the button visible.
    Note that opening the Mini App from the attachment menu hides the main button until the user interacts with the Mini App interface.
    hide()
    showProgress(leaveActive) FunctionA method to show a loading indicator on the button.
    It is recommended to display loading progress if the action tied to the button may take a long time. By default, the button is disabled while the action is in progress. If the parameter leaveActive=true is passed, the button remains enabled.
    A method to show a loading indicator on the button.
    It is recommended to display loading progress if the action tied to the button may take a long time. By default, the button is disabled while the action is in progress. If the parameter leaveActive=true is passed, the button remains enabled.
    hideProgress()
    setParams(params) FunctionA method to set the button parameters. The params parameter is an object containing one or several fields that need to be changed:
    text - button text;
    color - button color;
    text_color - button text color;
    is_active - enable the button;
    is_visible - show the button.
    A method to set the button parameters. The params parameter is an object containing one or several fields that need to be changed:
    text - button text;
    color - button color;
    text_color - button text color;
    is_active - enable the button;
    is_visible - show the button.

    All these methods return the MainButton object so they can be chained.

    -

    SettingsButton

    +

    SettingsButton

    This object controls the Settings item in the context menu of the Mini App in the Telegram interface.

    @@ -745,27 +749,27 @@ - + - + - + - +
    onClick(callback) Function==Bot API 7.0+== A method that sets the press event handler for the Settings item in the context menu. An alias for Telegram.WebApp.onEvent('settingsButtonClicked', callback)Bot API 7.0+ A method that sets the press event handler for the Settings item in the context menu. An alias for Telegram.WebApp.onEvent('settingsButtonClicked', callback)
    offClick(callback) Function==Bot API 7.0+== A method that removes the press event handler from the Settings item in the context menu. An alias for Telegram.WebApp.offEvent('settingsButtonClicked', callback)Bot API 7.0+ A method that removes the press event handler from the Settings item in the context menu. An alias for Telegram.WebApp.offEvent('settingsButtonClicked', callback)
    show() Function==Bot API 7.0+== A method to make the Settings item in the context menu visible.Bot API 7.0+ A method to make the Settings item in the context menu visible.
    hide() Function==Bot API 7.0+== A method to hide the Settings item in the context menu.Bot API 7.0+ A method to hide the Settings item in the context menu.

    All these methods return the SettingsButton object so they can be chained.

    -

    HapticFeedback

    +

    HapticFeedback

    This object controls haptic feedback.

    @@ -779,22 +783,22 @@ - + - + - +
    impactOccurred(style) Function==Bot API 6.1+== 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:
    - light, indicates a collision between small or lightweight UI objects,
    - medium, indicates a collision between medium-sized or medium-weight UI objects,
    - heavy, indicates a collision between large or heavyweight UI objects,
    - rigid, indicates a collision between hard or inflexible UI objects,
    - soft, indicates a collision between soft or flexible UI objects.
    Bot API 6.1+ 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:
    - light, indicates a collision between small or lightweight UI objects,
    - medium, indicates a collision between medium-sized or medium-weight UI objects,
    - heavy, indicates a collision between large or heavyweight UI objects,
    - rigid, indicates a collision between hard or inflexible UI objects,
    - soft, indicates a collision between soft or flexible UI objects.
    notificationOccurred(type) Function==Bot API 6.1+== 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:
    - error, indicates that a task or action has failed,
    - success, indicates that a task or action has completed successfully,
    - warning, indicates that a task or action produced a warning.
    Bot API 6.1+ 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:
    - error, indicates that a task or action has failed,
    - success, indicates that a task or action has completed successfully,
    - warning, indicates that a task or action produced a warning.
    selectionChanged() Function==Bot API 6.1+== A method tells that the user has changed a selection. The Telegram app may play the appropriate haptics.

    Do not use this feedback when the user makes or confirms a selection; use it only when the selection changes.
    Bot API 6.1+ A method tells that the user has changed a selection. The Telegram app may play the appropriate haptics.

    Do not use this feedback when the user makes or confirms a selection; use it only when the selection changes.

    All these methods return the HapticFeedback object so they can be chained.

    -

    CloudStorage

    +

    CloudStorage

    This object controls the cloud storage. Each bot can store up to 1024 items per user in the cloud storage.

    @@ -808,38 +812,38 @@ - + - + - + - + - + - +
    setItem(key, value[, callback]) Function==Bot API 6.9+== A method that stores a value in the cloud storage using the specified key. The key should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. The value should contain 0-4096 characters. You can store up to 1024 keys in the cloud storage. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the value was stored.Bot API 6.9+ A method that stores a value in the cloud storage using the specified key. The key should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. The value should contain 0-4096 characters. You can store up to 1024 keys in the cloud storage. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the value was stored.
    getItem(key, callback) Function==Bot API 6.9+== A method that receives a value from the cloud storage using the specified key. The key should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the value will be passed as the second argument.Bot API 6.9+ A method that receives a value from the cloud storage using the specified key. The key should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the value will be passed as the second argument.
    getItems(keys, callback) Function==Bot API 6.9+== A method that receives values from the cloud storage using the specified keys. The keys should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the values will be passed as the second argument.Bot API 6.9+ A method that receives values from the cloud storage using the specified keys. The keys should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the values will be passed as the second argument.
    removeItem(key[, callback]) Function==Bot API 6.9+== A method that removes a value from the cloud storage using the specified key. The key should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the value was removed.Bot API 6.9+ A method that removes a value from the cloud storage using the specified key. The key should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the value was removed.
    removeItems(keys[, callback]) Function==Bot API 6.9+== A method that removes values from the cloud storage using the specified keys. The keys should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the values were removed.Bot API 6.9+ A method that removes values from the cloud storage using the specified keys. The keys should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the values were removed.
    getKeys(callback) Function==Bot API 6.9+== A method that receives the list of all keys stored in the cloud storage. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the list of keys will be passed as the second argument.Bot API 6.9+ A method that receives the list of all keys stored in the cloud storage. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the list of keys will be passed as the second argument.

    All these methods return the CloudStorage object, so they can be chained.

    -

    BiometricManager

    -

    ^==NEW==^ This object controls biometrics on the device. Before the first use of this object, it needs to be initialized using the init method.

    +

    BiometricManager

    +

    NEW This object controls biometrics on the device. Before the first use of this object, it needs to be initialized using the init method.

    @@ -852,67 +856,67 @@ - + - + - + - + - + - + - + - + - + - + - + - +
    isInited Boolean==Bot API 7.2+== Shows whether biometrics object is initialized.Bot API 7.2+ Shows whether biometrics object is initialized.
    isBiometricAvailable Boolean==Bot API 7.2+== Shows whether biometrics is available on the current device.Bot API 7.2+ Shows whether biometrics is available on the current device.
    biometricType String==Bot API 7.2+== The type of biometrics currently available on the device. Can be one of these values:
    - finger, fingerprint-based biometrics,
    - face, face-based biometrics,
    - unknown, biometrics of an unknown type.
    Bot API 7.2+ The type of biometrics currently available on the device. Can be one of these values:
    - finger, fingerprint-based biometrics,
    - face, face-based biometrics,
    - unknown, biometrics of an unknown type.
    isAccessRequested Boolean==Bot API 7.2+== Shows whether permission to use biometrics has been requested.Bot API 7.2+ Shows whether permission to use biometrics has been requested.
    isAccessGranted Boolean==Bot API 7.2+== Shows whether permission to use biometrics has been granted.Bot API 7.2+ Shows whether permission to use biometrics has been granted.
    isBiometricTokenSaved Boolean==Bot API 7.2+== Shows whether the token is saved in secure storage on the device.Bot API 7.2+ Shows whether the token is saved in secure storage on the device.
    deviceId String==Bot API 7.2+== A unique device identifier that can be used to match the token to the device.Bot API 7.2+ A unique device identifier that can be used to match the token to the device.
    init([callback]) Function==Bot API 7.2+== A method that initializes the BiometricManager object. It should be called before the object's first use. If an optional callback parameter was passed, the callback function will be called when the object is initialized.Bot API 7.2+ A method that initializes the BiometricManager object. It should be called before the object's first use. If an optional callback parameter was passed, the callback function will be called when the object is initialized.
    requestAccess(params[, callback]) Function==Bot API 7.2+== A method that requests permission to use biometrics according to the params argument of type BiometricRequestAccessParams. If an optional callback parameter was passed, the callback function will be called and the first argument will be a boolean indicating whether the user granted access.Bot API 7.2+ A method that requests permission to use biometrics according to the params argument of type BiometricRequestAccessParams. If an optional callback parameter was passed, the callback function will be called and the first argument will be a boolean indicating whether the user granted access.
    authenticate(params[, callback]) Function==Bot API 7.2+== A method that authenticates the user using biometrics according to the params argument of type BiometricAuthenticateParams. If an optional callback parameter was passed, the callback function will be called and the first argument will be a boolean indicating whether the user authenticated successfully. If so, the second argument will be a biometric token.Bot API 7.2+ A method that authenticates the user using biometrics according to the params argument of type BiometricAuthenticateParams. If an optional callback parameter was passed, the callback function will be called and the first argument will be a boolean indicating whether the user authenticated successfully. If so, the second argument will be a biometric token.
    updateBiometricToken(token, [callback]) Function==Bot API 7.2+== A method that updates the biometric token in secure storage on the device. To remove the token, pass an empty string. If an optional callback parameter was passed, the callback function will be called and the first argument will be a boolean indicating whether the token was updated.Bot API 7.2+ A method that updates the biometric token in secure storage on the device. To remove the token, pass an empty string. If an optional callback parameter was passed, the callback function will be called and the first argument will be a boolean indicating whether the token was updated.
    openSettings() Function==Bot API 7.2+== A method that opens the biometric access settings for bots. Useful when you need to request biometrics access to users who haven't granted it yet.

    Note that this method can be called only in response to user interaction with the Mini App interface (e.g. a click inside the Mini App or on the main button)
    Bot API 7.2+ A method that opens the biometric access settings for bots. Useful when you need to request biometrics access to users who haven't granted it yet.

    Note that this method can be called only in response to user interaction with the Mini App interface (e.g. a click inside the Mini App or on the main button)

    All these methods return the BiometricManager object so they can be chained.

    -

    BiometricRequestAccessParams

    +

    BiometricRequestAccessParams

    This object describes the native popup for requesting permission to use biometrics.

    @@ -930,7 +934,7 @@
    -

    BiometricAuthenticateParams

    +

    BiometricAuthenticateParams

    This object describes the native popup for authenticating the user using biometrics.

    @@ -948,7 +952,7 @@
    -

    WebAppInitData

    +

    WebAppInitData

    This object contains data that is transferred to the Mini App when it is opened. It is empty if the Mini App was launched from a keyboard button or from inline mode.

    @@ -982,7 +986,7 @@ - + @@ -992,7 +996,7 @@ - + @@ -1011,7 +1015,7 @@
    chat_type StringOptional. Type of the chat from which the Mini App was opened. Can be either "sender" for a private chat with the user opening the link, "private", "group", "supergroup", or "channel". Returned only for Mini Apps launched from direct links.Optional. Type of the chat from which the Mini App was opened. Can be either “sender” for a private chat with the user opening the link, “private”, “group”, “supergroup”, or “channel”. Returned only for Mini Apps launched from direct links.
    chat_instance
    start_param StringOptional. The value of the startattach parameter, passed via link. Only returned for Mini Apps when launched from the attachment menu via link.

    The value of the start_param parameter will also be passed in the GET-parameter tgWebAppStartParam, so the Mini App can load the correct interface right away.
    Optional. The value of the startattach parameter, passed via link. Only returned for Mini Apps when launched from the attachment menu via link.

    The value of the start_param parameter will also be passed in the GET-parameter tgWebAppStartParam, so the Mini App can load the correct interface right away.
    can_send_after
    -

    WebAppUser

    +

    WebAppUser

    This object contains the data of the Mini App user.

    @@ -1050,7 +1054,7 @@ - + @@ -1074,7 +1078,7 @@
    language_code StringOptional. IETF language tag of the user's language. Returns in user field only.Optional. IETF language tag of the user's language. Returns in user field only.
    is_premium
    -

    WebAppChat

    +

    WebAppChat

    This object represents a chat.

    @@ -1093,7 +1097,7 @@ - + @@ -1112,19 +1116,19 @@
    type StringType of chat, can be either "group", "supergroup" or "channel"Type of chat, can be either “group”, “supergroup” or “channel”
    title
    -

    Validating data received via the Mini App

    -

    To validate data received via the Mini App, one should send the data from the Telegram.WebApp.initData field to the bot's backend. The data is a query string, which is composed of a series of field-value pairs.

    -

    You can verify the integrity of the data received by comparing the received hash parameter with the hexadecimal representation of the HMAC-SHA-256 signature of the data-check-string with the secret key, which is the HMAC-SHA-256 signature of the bot's token with the constant string WebAppData used as a key.

    -

    Data-check-string is a chain of all received fields, sorted alphabetically, in the format key=<value> with a line feed character ('\n', 0x0A) used as separator – e.g., 'auth_date=<auth_date>\nquery_id=<query_id>\nuser=<user>'.

    +

    Validating data received via the Mini App

    +

    To validate data received via the Mini App, one should send the data from the Telegram.WebApp.initData field to the bot's backend. The data is a query string, which is composed of a series of field-value pairs.

    +

    You can verify the integrity of the data received by comparing the received hash parameter with the hexadecimal representation of the HMAC-SHA-256 signature of the data-check-string with the secret key, which is the HMAC-SHA-256 signature of the bot's token with the constant string WebAppData used as a key.

    +

    Data-check-string is a chain of all received fields, sorted alphabetically, in the format key=<value> with a line feed character ('\n', 0x0A) used as separator – e.g., 'auth_date=<auth_date>\nquery_id=<query_id>\nuser=<user>'.

    The full check might look like:

    data_check_string = ...
    -secret_key = HMAC_SHA256(<bot_token>, "WebAppData")
    +secret_key = HMAC_SHA256(<bot_token>, "WebAppData")
     if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
       // data is from Telegram
     }

    To prevent the use of outdated data, you can additionally check the auth_date field, which contains a Unix timestamp of when it was received by the Mini App.

    Once validated, the data may be used on your server. Complex data types are represented as JSON-serialized objects.

    -

    Events Available for Mini Apps

    +

    Events Available for Mini Apps

    The Mini App can receive events from the Telegram app, onto which a handler can be attached using the Telegram.WebApp.onEvent(eventType, eventHandler) method. Inside eventHandler the this object refers to Telegram.WebApp, the set of parameters sent to the handler depends on the event type. Below is a list of possible events:

    @@ -1136,84 +1140,78 @@ if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) { - + - + - + - + - + - + - + - + - + - + - + - + - + - +
    themeChangedOccurs whenever theme settings are changed in the user's Telegram app (including switching to night mode).
    eventHandler receives no parameters, new theme settings and color scheme can be received via this.themeParams and this.colorScheme respectively.
    Occurs whenever theme settings are changed in the user's Telegram app (including switching to night mode).
    eventHandler receives no parameters, new theme settings and color scheme can be received via this.themeParams and this.colorScheme respectively.
    viewportChangedOccurs when the visible section of the Mini App is changed.
    eventHandler receives an object with the single field isStateStable. If isStateStable is true, the resizing of the Mini App is finished. If it is false, the resizing is ongoing (the user is expanding or collapsing the Mini App or an animated object is playing). The current value of the visible section’s height is available in this.viewportHeight.
    Occurs when the visible section of the Mini App is changed.
    eventHandler receives an object with the single field isStateStable. If isStateStable is true, the resizing of the Mini App is finished. If it is false, the resizing is ongoing (the user is expanding or collapsing the Mini App or an animated object is playing). The current value of the visible section’s height is available in this.viewportHeight.
    mainButtonClickedOccurs when the main button is pressed.
    eventHandler receives no parameters.
    Occurs when the main button is pressed.
    eventHandler receives no parameters.
    backButtonClicked==Bot API 6.1+== Occurrs when the back button is pressed.
    eventHandler receives no parameters.
    Bot API 6.1+ Occurrs when the back button is pressed.
    eventHandler receives no parameters.
    settingsButtonClicked==Bot API 6.1+== Occurrs when the Settings item in context menu is pressed.
    eventHandler receives no parameters.
    Bot API 6.1+ Occurrs when the Settings item in context menu is pressed.
    eventHandler receives no parameters.
    invoiceClosed==Bot API 6.1+== Occurrs when the opened invoice is closed.
    eventHandler receives an object with the two fields: url – invoice link provided and status – one of the invoice statuses:
    - paid – invoice was paid successfully,
    - cancelled – user closed this invoice without paying,
    - failed – user tried to pay, but the payment was failed,
    - pending – the payment is still processing. The bot will receive a service message about a successful payment when the payment is successfully paid.
    Bot API 6.1+ Occurrs when the opened invoice is closed.
    eventHandler receives an object with the two fields: url – invoice link provided and status – one of the invoice statuses:
    - paid – invoice was paid successfully,
    - cancelled – user closed this invoice without paying,
    - failed – user tried to pay, but the payment was failed,
    - pending – the payment is still processing. The bot will receive a service message about a successful payment when the payment is successfully paid.
    popupClosed==Bot API 6.2+== Occurrs when the opened popup is closed.
    eventHandler receives an object with the single field button_id – the value of the field id of the pressed button. If no buttons were pressed, the field button_id will be null.
    Bot API 6.2+ Occurrs when the opened popup is closed.
    eventHandler receives an object with the single field button_id – the value of the field id of the pressed button. If no buttons were pressed, the field button_id will be null.
    qrTextReceived==Bot API 6.4+== Occurs when the QR code scanner catches a code with text data.
    eventHandler receives an object with the single field data containing text data from the QR code.
    Bot API 6.4+ Occurs when the QR code scanner catches a code with text data.
    eventHandler receives an object with the single field data containing text data from the QR code.
    clipboardTextReceived==Bot API 6.4+== Occurrs when the readTextFromClipboard method is called.
    eventHandler receives an object with the single field data containing text data from the clipboard. If the clipboard contains non-text data, the field data will be an empty string. If the Mini App has no access to the clipboard, the field data will be null.
    Bot API 6.4+ Occurrs when the readTextFromClipboard method is called.
    eventHandler receives an object with the single field data containing text data from the clipboard. If the clipboard contains non-text data, the field data will be an empty string. If the Mini App has no access to the clipboard, the field data will be null.
    writeAccessRequested==Bot API 6.9+== Occurs when the write permission was requested.
    eventHandler receives an object with the single field status containing one of the statuses:
    - allowed – user granted write permission to the bot,
    - cancelled – user declined this request.
    Bot API 6.9+ Occurs when the write permission was requested.
    eventHandler receives an object with the single field status containing one of the statuses:
    - allowed – user granted write permission to the bot,
    - cancelled – user declined this request.
    contactRequested==Bot API 6.9+== Occurrs when the user's phone number was requested.
    eventHandler receives an object with the single field status containing one of the statuses:
    - sent – user shared their phone number with the bot,
    - cancelled – user declined this request.
    Bot API 6.9+ Occurrs when the user's phone number was requested.
    eventHandler receives an object with the single field status containing one of the statuses:
    - sent – user shared their phone number with the bot,
    - cancelled – user declined this request.
    biometricManagerUpdated==Bot API 7.2+== Occurs whenever BiometricManager object is changed.
    eventHandler receives no parameters.
    Bot API 7.2+ Occurs whenever BiometricManager object is changed.
    eventHandler receives no parameters.
    biometricAuthRequested==Bot API 7.2+== Occurs whenever biometric authentication was requested.
    eventHandler receives an object with the field isAuthenticated containing a boolean indicating whether the user was authenticated successfully. If isAuthenticated is true, the field biometricToken will contain the biometric token stored in secure storage on the device.
    Bot API 7.2+ Occurs whenever biometric authentication was requested.
    eventHandler receives an object with the field isAuthenticated containing a boolean indicating whether the user was authenticated successfully. If isAuthenticated is true, the field biometricToken will contain the biometric token stored in secure storage on the device.
    biometricTokenUpdated==Bot API 7.2+== Occurs whenever the biometric token was updated.
    eventHandler receives an object with the single field isUpdated, containing a boolean indicating whether the token was updated.
    Bot API 7.2+ Occurs whenever the biometric token was updated.
    eventHandler receives an object with the single field isUpdated, containing a boolean indicating whether the token was updated.
    -

    Adding Bots to the Attachment Menu

    -

    Attachment menu integration is currently only available for major advertisers on the Telegram Ad Platform. However, all bots can use it in the test server environment. Talk to Botfather on the test server to set up the integration.

    +

    Adding Bots to the Attachment Menu

    +

    Attachment menu integration is currently only available for major advertisers on the Telegram Ad Platform. However, all bots can use it in the test server environment. Talk to Botfather on the test server to set up the integration.

    A special link is used to add bots to the attachment menu:

    -

    https://t.me/botusername?startattach -or -https://t.me/botusername?startattach=command

    +

    https://t.me/botusername?startattach
    or
    https://t.me/botusername?startattach=command

    -

    For example, open this attachment menu link for @DurgerKingBot, then use the Attach menu in any private chat.

    +

    For example, open this attachment menu link for @DurgerKingBot, then use the Attach menu in any private chat.

    Opening the link prompts the user to add the bot to their attachment menu. If the bot has already been added, the attachment menu will open in the current chat and redirect to the bot there (if the link is opened from a 1-on-1 chat). If a non-empty startattach parameter was included in the link, it will be passed to the Mini App in the start_param field and in the GET parameter tgWebAppStartParam.

    The following link formats are also supported:

    -

    https://t.me/username?attach=botusername -https://t.me/username?attach=botusername&startattach=command -https://t.me/+1234567890?attach=botusername -https://t.me/+1234567890?attach=botusername&startattach=command

    -

    These links open the Mini App in the attachment menu in the chat with a specific user. If the bot wasn't already added to the attachment menu, the user will be prompted to do so. If a non-empty startattach parameter was included in the link, it will be passed to the Mini App in the start_param field and in the GET parameter tgWebAppStartParam.

    -

    ==Bot API 6.1+== supports a new link format:

    -

    https://t.me/botusername?startattach&choose=users+bots -https://t.me/botusername?startattach=command&choose=groups+channels

    -

    Opening such a link prompts the user to choose a specific chat and opens the attachment menu in that chat. If the bot wasn'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: users, bots, groups, channels separated by a + sign. If a non-empty startattach parameter was included in the link, it will be passed to the Mini App in the start_param field and in the GET parameter tgWebAppStartParam.

    -

    Testing Mini Apps

    -

    Using bots in the test environment

    +

    https://t.me/username?attach=botusername
    https://t.me/username?attach=botusername&startattach=command
    https://t.me/+1234567890?attach=botusername
    https://t.me/+1234567890?attach=botusername&startattach=command

    +

    These links open the Mini App in the attachment menu in the chat with a specific user. If the bot wasn't already added to the attachment menu, the user will be prompted to do so. If a non-empty startattach parameter was included in the link, it will be passed to the Mini App in the start_param field and in the GET parameter tgWebAppStartParam.

    +

    Bot API 6.1+ supports a new link format:

    +

    https://t.me/botusername?startattach&choose=users+bots
    https://t.me/botusername?startattach=command&choose=groups+channels

    +

    Opening such a link prompts the user to choose a specific chat and opens the attachment menu in that chat. If the bot wasn'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: users, bots, groups, channels separated by a + sign. If a non-empty startattach parameter was included in the link, it will be passed to the Mini App in the start_param field and in the GET parameter tgWebAppStartParam.

    +

    Testing Mini Apps

    +

    Using bots in the test environment

    To log in to the test environment, use either of the following:

    +