xynobo / telegram-web-app-bot-example

Telegram Web App for Bot Example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Telegram Web Apps for Bots test

Example HTML-file that contains a basic interaction with Telegram Web Apps API. Based on Attach Bot.

Links

Quick setup

1. Show the user a button to open a Web App. There are two ways:

  1. Show the user a special menu button (near the message input field):

    1. Go to Bot Father
    2. Select your bot
    3. Bot SettingsMenu ButtonSpecify../Edit menu button URL
    4. Send a URL to your Web App (e.g. https://example.com/telegram-web-app/index.html)
  2. The second way is to send a button with the data that contains field web_app with a URL to a Web App:

    {
        "text": "Test web_app",
        "web_app": {
            "url": "https://example.com/telegram-web-app/index.html"
        }
    }

2. Add script to your Web App

To connect a Web App to the Telegram client, place the script telegram-web-app.js in the <head> tag before any other scripts, using this code (more info):

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

Once the script is connected, a window.Telegram.WebApp object will become available.

3. Do the thing.

About

Telegram Web App for Bot Example


Languages

Language:HTML 100.0%