Integrating claimr widget into Telegram mini app
Last updated
Was this helpful?
Last updated
Was this helpful?
You can integrate the claimr widget into the Telegram Mini App. This setup allows you to leverage claimr's engagement features seamlessly within the Telegram environment, automatically utilizing the user's Telegram context.
This article demonstrates how to:
Dynamically inject the claimr widget tailored for Telegram.
Understand the interaction between the claimr widget and the Telegram Mini App API.
Configure the required claimr campaign settings for Telegram integration.
Main files :
src/claimr_wrapper.tsx
: Handles claimr widget injection and configuration.
src/example_app.tsx
: Main UI component demonstrating Telegram API initialization.
Ensure you have the following installed:
Node.js (v18+ recommended) –
npm or yarn – Comes with Node.js (or )
Open a terminal and follow these steps:
Navigate to the project folder:
Install dependencies:
Using npm:
Using Yarn:
Start the development server:
Using npm:
Using Yarn:
View in browser: The app will be available at: http://localhost:3000
Note: For full Telegram Mini App functionality testing, you'll need to run this within the Telegram environment.
To create a production-ready build:
or:
This will create a build/
folder.
claimr_wrapper.tsx
)The ClaimrWrapper
component is responsible for dynamically injecting the claimr widget script into your application page.
Script Source
The widget script is loaded from: https://widgets.claimr.io/claimr.min.js
Script Attributes
It’s injected with the following custom attributes:
Purpose of attributes:
This lets the widget know:
where to render (container ID),
which organization and campaign to load,
which features (addons) to enable,
and that it’s running in a Telegram context.
The wrapper ensures this script is injected only once per session.
example_app.tsx
)This component demonstrates initializing the Telegram Mini App API to ensure the webview behaves correctly within Telegram:
These standard Telegram Mini App API functions:
expand()
: Maximizes the Mini App window.
enableClosingConfirmation()
: Prompts the user before they close the Mini App.
disableVerticalSwipes()
: Prevents vertical swipes from accidentally closing or navigating away from the Mini App.
A Telegram user opens your Mini App containing the claimr integration.
The ClaimrWrapper
injects the widget script with the data-platform='telegram'
attribute.
The claimr widget initializes and reads the window.Telegram.WebApp
context to automatically identify the Telegram user (using their Telegram ID and other available data).
The widget displays relevant tasks or quests based on the campaign configuration and the identified user.
If necessary for specific tasks, the widget might prompt the user to link other accounts (like Discord, email, or a wallet) through separate flows within the widget.
Task completions and results are synced back to claimr's backend, associated with the user's Telegram identity.
To ensure the claimr widget functions correctly within your Telegram Mini App and automatically recognizes users, specific campaign settings are required.
Navigate to Sign-in options:
Open your claimr dashboard.
Go to your specific campaign.
Click on Settings.
Select Sign-in options.
Set the following parameter:
Select sign-in services: Ensure that Telegram is selected in this field. This explicitly allows users to authenticate and interact with your campaign using their Telegram identity provided by the Mini App environment.