Skip to main content

Step-by-step guide

Telegram Mini Apps (TMA) are web applications that run inside the Telegram app. They are built using web technologies, including HTML, CSS, and JavaScript. TMAs can be used to create apps and games.

Create your Mini App

  1. To connect your Mini App to Telegram, add the SDK script telegram-web-app.js using this code:
<script src="https://telegram.org/js/telegram-web-app.js"></script>
tip

It's best to disable caching using HTTP response headers. To ensure caching is disabled, configure these headers in your server responses:

Cache-Control: no-store, must-revalidate
Pragma: no-cache
Expires: 0
  1. Once the script is loaded, the window.Telegram.WebApp object becomes available. Learn more about creating a Mini App using telegram-web-app.js.

  2. You can also use the @twa-dev/sdk npm package:

npm install @twa-dev/sdk

See the Modern TMA example for @twa-dev/sdk in this guide.

  1. Once your Mini App is deployed, continue with Setting up a bot for the Mini App.

Setting up a bot for the Mini App

To connect your Mini App to Telegram, you need to create a bot and set up a Mini App for it. Follow these steps:

1. Start a chat with BotFather

  • Open the Telegram app or web version.
  • Search for @BotFather in the search bar or click this link @BotFather.
  • Start a chat with BotFather by clicking START.

2. Create a new bot

  • Send the /newbot command to BotFather.
  • Choose a display name for your bot. It can include spaces.
  • Choose a unique username for your bot that ends with bot, such as sample_bot.

3. Set up the Mini App for the bot

  • Send the /mybots command to @BotFather.
  • Select your bot from the list and choose Bot Settings.
  • Select Menu Button.
  • Choose Edit menu button URL and enter the URL when prompted by BotFather (e.g., a link from GitHub pages deployment).

4. Access the bot

  • Search for your bot using its username in Telegram's search bar.
  • Tap the Menu button (next to the attachment icon) to launch your Telegram Mini App.
Was this article useful?