Learn how to integrate Web SDK with your Telegram Mini-app or Game for seamless web3 functionality.
This guide will walk you through setting up Web SDK with your Telegram Mini-app or Game, enabling web3 functionality on EVM chains for your users for email and guest authentication methods.
Before starting, ensure you have:
Create a Telegram Bot with BotFather
/start
/newbot
Obtain Required Tokens
After creating your bot, BotFather will provide:
Save these credentials - you’ll need them for the next steps.
Never share or commit your bot token. It should be treated as a secret.
Install and Configure Your Project
Update the .env
file with the VITE_PROJECT_ACCESS_KEY
and VITE_WAAS_CONFIG_KEY
with your keys from Sequence Builder after configuration.
VARS
in the wrangler.toml
file with a user provided secret for BOT_SECRET
and the bot token from BotFather for BOT_TOKEN
.Authenticate with Cloudflare Account
Deploy the app and functions logic to Cloudflare
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.
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!
For your BOT_TOKEN
, you can encrypt and store it in Cloudflare via the following command to prevent data leaks:
Enter in your bot token when prompted.