Telegram Mini Apps

Mini App bot API MiniApp example project

If standard Telegram Bot features aren't enough to fit your needs, you may want to consider building a Mini App instead.

This take the form of an integrated browser window showing directly web pages from your bot WebApp, so you have more control with HTML/JS to display the interface you like.

Check our full example project based on Razor pages, and including a clone of the above @DurgerKingBot and more demo to test features.

Starting Mini-Apps

Mini Apps can be launched from various ways:

  • Keyboard Buttons: KeyboardButton.WithWebApp
  • Inline Buttons: InlineKeyboardButton.WithWebApp
  • Chat menu button (left of user textbox): via @BotFather or SetChatMenuButtonAsync
  • Inline-mode results with a "Switch to Mini App" button: AnswerInlineQueryAsync with parameter InlineQueryResultsButton.WebApp
  • Direct link like https://t.me/botusername/appname?startapp=command

Integration

Your web pages must include this script in the <head> part:

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

Your Javascript can then access a Telegram.WebApp object supporting many properties and methods, as well as event handlers.

In particular, you may want to use your Telegram.Bot backend to validate the authenticity of Telegram.WebApp.initData.

This can be done using our AuthHelpers.ParseValidateData method and the bot token, to make sure the requests come from Telegram and obtain information about Telegram user and context.

For more details

To read more about Mini Apps, see https://core.telegram.org/bots/webapps

Visit our example project: https://github.com/TelegramBots/Telegram.Bot.Examples/tree/master/MiniApp