- Bot-first: Users first create and interact with their wallet via Telegram commands to the bot in the Telegram app itself. Later, the user can “claim” their wallet by logging into a web or mobile app to send transactions and export their private key from that interface. Users can also eventually revoke permissions for the bot to transact on their behalf.
- App-first: Users first create and interact with their wallet by logging into a web or mobile app with their Telegram account, or logging in with an alternate method and then linking their Telegram account. They can send transactions and export their private key from the app, and can also grant permissions to the bot to transact on their behalf.
Configuring your bot
To start, we’ll cover the basics of creating and setting up your Telegram bot that can send transactions.Creating a bot
First, create a new Telegram bot if you haven’t already following the instructions below.Setting up commands
Next, enable your users to interact with the bot via the Telegram app by configuring your bot to respond to Telegram commands. Use the bot’sonText
interface to register Telegram commands and the actions they should execute.
For example, you might register a /createwallet
command for users to create wallets via the Telegram app, or a /transact
command for users to be able to transact.
Associating your user’s wallet ID with their Telegram user ID
In order for the Telegram bot to interact with a user’s wallet, the bot must be able to determine what the user’s wallet ID is.Bot-first setup
At a high-level, the bot-first setup works by creating a wallet associated with your user’s Telegram handle, allowing them to transact with the wallet via commands made to your bot, and enabling users to claim their wallet or control it from a web or mobile app if desired. Follow the steps below for more concrete guidance.1
Create a wallet associated with your user
First, create a user in Privy and a wallet owned by that user. To allow your bot to transact on behalf of the user, create an authorization key and add it as an additional signer on the wallet.
2
Send transactions with the wallet
Next, allow the user to transact with commands send to the bot. You might implement a
/transact
command that takes input on the user to transact on their behalf.Make sure to configure your Privy client with the private key for the authorization key you created in the Dashboard.
3
Allow the user to claim their wallet and use it from your app
If you’d like users to be able to claim their wallet via a web or mobile app, configure your web app with Privy’s React SDK or your mobile app with Privy’s React Native SDK and enable Telegram login.Then, when users login to your app via Telegram, they can send transactions or export their private keys.
App-first setup
At a high-level, the app-first setup works by creating a wallet associated with your user when they login to your app with Telegram (or alternatively, link a Telegram account) and then adding a session signer to the wallet to allow the bot to transact on behalf of your user. Follow the steps below for more concrete guidance.1
Instrument your app with Privy
If you have not already done so, instrument your web app with Privy’s React SDK or your mobile app with Privy’s React Native SDK and enable Telegram login.
2
Create wallets for your users
When your users login to your app with Telegram or link a Telegram account, create a wallet for them. Store a mapping between the ID of the created wallet and the user’s Telegram ID so that you can determine the user’s wallet within the bot’s code.
3
Add a session signer to the user's wallet
After the wallet has been created, add a session signer to the user’s wallet, which the bot can use to transact on the user’s behalf.Make sure to store the private key(s) associated with your signer ID securely in your server. Your Telegram bot or agent will need this to execute transaction requests.Follow the linked quickstart below to learn how to add a session signer to the user’s wallet.
4
Execute actions with your signer
Finally, the bot can use the session signer to execute transactions on the user’s behalf when prompted. For instance, you might implement a
/transact
command that takes input on the user to transact on their behalf.Make sure to configure your Privy client with the private key for the session signer (authorization key) you created in the Dashboard.