⚡
claimr
  • Getting started
    • Create an account
    • Sign in to your account
    • Reset password
    • Edit profile
  • ⚡️claimr core components
  • Team roles and management
  • Campaigns
    • Create new campaign
    • Campaign settings
  • Groups
    • Create new group
    • Group settings
  • Quests
    • Create new quest
    • Quest settings
  • Tasks
    • Create new task
    • Task settings
    • Telegram tasks
    • X (Twitter) tasks
    • TikTok tasks
    • Discord tasks
    • YouTube tasks
    • Web3 tasks
      • Connect a wallet
      • Transactions count
      • Wallet balance
      • Token balance
      • NFT balance
      • Link3 balance
      • Mint an NFT (721)
      • Mint an NFT (1155)
      • Verify transactions
    • PoW tasks
    • HTTP request tasks
    • Referral tasks
    • Form tasks
    • Poll tasks
    • Events tasks
    • API tasks
  • Widget
    • Publish campaign
    • Widget configurations
    • Widget attributes
    • Integrate claimr widget into your website
    • claimr widget integrations
      • Google Analytics integration
      • Google Analytics Client ID
      • Google Tag Manager integration
      • HotJar integration
  • Rewards
    • Reward settings
    • Custom rewards
  • Events
    • Daily check-ins
    • Challenges
    • Ranks
    • KOLs
  • Codes
    • Secret codes
    • Invite codes
      • Enter invite code task
      • Claim invite code task
    • Gift codes
  • Test users
  • Pop-ups
    • Into pop-up
    • Completion pop-up
  • API
    • API token
    • API methods
    • User token
  • Webhooks
    • Set up webhooks
    • Assign webhooks
    • Webhook scopes
  • SDK
  • Forms
    • Create forms
    • Form settings
    • Pages
    • Blocks
    • Quizzes
  • Data analytics
    • Activity
    • PoW analytics
    • User information
    • Failed actions
    • Issues analytics
  • How to
    • Create X campaign
    • Create Discord campaign
    • Integrate claimr widget into dApp
    • Integrating claimr widget into Telegram mini app
    • Customize user experience with tags and attributes
    • Add custom points to users
  • UX requirements
    • Campaign UX requirements
    • Group UX requirements
    • Quest card UX requirements
    • Quest UX requirements
    • Task UX requirements
    • User progress UX requirements
    • Pop-ups UX requirements
    • Interactive components UX requirements
Powered by GitBook
On this page
  • Introduction
  • Running the project
  • Optional: Build for production
  • claimr Widget integration (claimr_wrapper.tsx)
  • Telegram mini app behavior (example_app.tsx)
  • How it works (User view)
  • Campaign configuration: required settings

Was this helpful?

  1. How to

Integrating claimr widget into Telegram mini app

PreviousIntegrate claimr widget into dAppNextCustomize user experience with tags and attributes

Last updated 29 days ago

Was this helpful?

Introduction

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 )

Running the project

Open a terminal and follow these steps:

  1. Navigate to the project folder:

    cd path/to/claimr-tg-app-example
  2. Install dependencies:

    Using npm:

    npm install

    Using Yarn:

    yarn
  3. Start the development server:

    Using npm:

    npm start

    Using Yarn:

    yarn start
  4. 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.

Optional: Build for production

To create a production-ready build:

npm run build

or:

yarn build

This will create a build/ folder.

claimr Widget integration (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:

 script.setAttribute('data-container', CLAIMR_CONTAINER_ID);
 script.setAttribute('data-organization', 'claimr');
 script.setAttribute('data-campaign', 'telegram-mini-app');
 script.setAttribute('data-addons', 'sup,eap,eup,pvm,dcc');
 script.setAttribute('data-autoresize', 'true');
 script.setAttribute('data-platform', 'telegram');

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.

Telegram mini app behavior (example_app.tsx)

This component demonstrates initializing the Telegram Mini App API to ensure the webview behaves correctly within Telegram:

useEffect(() => {
  window.Telegram?.WebApp?.expand();
  window.Telegram?.WebApp?.enableClosingConfirmation();
  window.Telegram?.WebApp?.disableVerticalSwipes();
}, []);

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.

How it works (User view)

  1. A Telegram user opens your Mini App containing the claimr integration.

  2. The ClaimrWrapper injects the widget script with the data-platform='telegram' attribute.

  3. 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).

  4. The widget displays relevant tasks or quests based on the campaign configuration and the identified user.

  5. 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.

  6. Task completions and results are synced back to claimr's backend, associated with the user's Telegram identity.

Campaign configuration: required settings

To ensure the claimr widget functions correctly within your Telegram Mini App and automatically recognizes users, specific campaign settings are required.

  1. Navigate to Sign-in options:

    • Open your claimr dashboard.

    • Go to your specific campaign.

    • Click on Settings.

    • Select Sign-in options.

  2. 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.

Install Node.js
install Yarn separately