Example HTML-file that contains a basic interaction with Telegram Web Apps API. Based on Attach Bot.
- Official docs: https://core.telegram.org/bots/webapps
- Live Demo Bot: Attach Bot
- Telegram Promo Bot: Durger King
- My Telegram WebApp to track movies and TV shows: EPSCAPE Bot
-
Show the user a special menu button (near the message input field):
- Go to Bot Father
- Select your bot
Bot Settings
—Menu Button
—Specify..
/Edit menu button URL
- Send a URL to your Web App (e.g.
https://example.com/telegram-web-app/index.html
)
-
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" } }
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.