Integrating Sequence Kit with Telegram Mini-apps
This guide will walk you through setting up Sequence Kit with your Telegram Mini-app or Game, enabling web3 functionality on EVM chains for your users for email and guest authentication methods.
Prerequisites
Before starting, ensure you have:
- A Telegram account
- Account and Access to Cloudflare Dashboard
Integration Steps
Create a Telegram Bot with BotFather
- Open Telegram and search for "@BotFather"
- Start a conversation by clicking "Start" or typing
/start
- Create a new bot by typing
/newbot
- Follow the prompts:
- Enter a name for your bot
- Choose a username (must end in 'bot')
Obtain Required Tokens
After creating your bot, BotFather will provide:
- Bot Token (HTTP API Token)
- Bot Username
Save these credentials - you'll need them for the next steps.
Install and Configure Your Project
- Clone the Sequence Telegram starter:
git clone https://github.com/0xsequence-demos/telegram-kit-embedded-wallet-react-boilerplate
- Copy the example files in your project root:
cp .env.example .env && cp example.wrangler.toml wrangler.toml
Update the .env
file with the VITE_PROJECT_ACCESS_KEY
and VITE_WAAS_CONFIG_KEY
with your keys from Sequence Builder after configuration.
- Install dependencies:
pnpm install
- Build the app:
pnpm run build
- Update the
VARS
in thewrangler.toml
file with a user provided secret forBOT_SECRET
and the bot token from BotFather forBOT_TOKEN
.
Authenticate with Cloudflare Account
Deploy the app and functions logic to Cloudflare
- Run
pnpm wrangler pages deploy
This will prompt you to authenticate with Cloudflare if not already logged in. On successful deploy, copy the URL where your application is now hosted.
Register Webhook with Telegram
Now we call our registerWebhook
endpoint on our app to register the webhook function with the URL of your deployed application to enable access for the Telegram API.
curl -X POST \
"<YOUR_CLOUDFLARE_DEPLOYED_URL>/api/registerWebhook"
Update Allowed Origins
Ensure in your wallet configuration you have added the URL of your deployed application as an allowed origin through the configuration page on Sequence Builder.
Test out the Bot!
Send a message to your bot on Telegram and see if it responds! It should answer you with the ability to share, play and get more info on bot.
From here, you have a fully functional Telegram bot that can interact with Sequence Embedded wallets for all integrated EVM chains. You can customize the bot responses and the client side application with functionalities specific to your game or app - simply redeploy and update the allowed origins!
Going to production
For your BOT_TOKEN
, you can encrypt and store it in Cloudflare via the following command to prevent data leaks:
pnpm wrangler pages secret put BOT_TOKEN
Enter in your bot token when prompted.