- Configure the campaign to sign users in with Telegram.
- Load Telegram’s Mini App script and the Claimr widget in Telegram mode.
- Set up the Mini App window so the widget is comfortable to use.
Prerequisites
- A Telegram bot with a Mini App configured through @BotFather.
- A web app that you serve as the Mini App, with the Claimr widget set up as described in Integrate Claimr into a React app.
Configure the campaign
In the Claimr admin panel, open your campaign, click Settings, then select Sign-in options. In Select sign-in services, make sure Telegram is selected. This lets users take part in the campaign with the Telegram identity the Mini App provides.
Set up the Mini App
1
Load Telegram's Mini App script
Add Telegram’s script to the This script creates
<head> of your app’s HTML page, before your own scripts:index.html
window.Telegram.WebApp. The Claimr widget reads the user’s Telegram identity from it, so without it the widget cannot sign the user in.2
Load the widget in Telegram mode
Add If you embed the script tag directly instead of using the loader, add
platform: 'telegram' to the loader configuration in your Claimr provider:data-platform="telegram" to it.3
Configure the Mini App window
When your app starts, expand the Mini App to full height and stop accidental closing:
src/App.tsx
expand()maximizes the Mini App window.enableClosingConfirmation()asks the user to confirm before closing the Mini App.disableVerticalSwipes()stops vertical swipes from closing the Mini App while the user scrolls the widget.
@types/telegram-web-app to get types for window.Telegram.4
Test inside Telegram
Open the Mini App from your bot in the Telegram app. Outside Telegram,
window.Telegram.WebApp has no user data, so the widget cannot sign anyone in automatically.How it works
- A user opens your Mini App in Telegram.
- Your app loads the Claimr widget with
platform: 'telegram'. - The widget reads the Mini App context from
window.Telegram.WebAppand signs the user in with their Telegram account. - The widget shows the campaign’s quests and tasks for that user.
- If a task needs another account, such as Discord, email, or a wallet, the widget asks the user to link it.
- Task completions are saved to the user’s Claimr profile, linked to their Telegram identity.