This guide will help you set up and run Eliza with Telegram integration.
Before starting, make sure you have:
- A Telegram account
- Access to my.telegram.org/apps
- Node.js and pnpm installed
- Visit my.telegram.org/apps
- Log in with your Telegram account
- Create a new application if you haven't already
- Note down the following credentials:
- API ID
- API Hash
- Phone Number (in international format, e.g., +1234567890)
Copy the following variables to your .env
file and fill in your credentials:
# Telegram Configuration
TELEGRAM_API_ID= # API ID from my.telegram.org/apps
TELEGRAM_API_HASH= # API Hash from my.telegram.org/apps
TELEGRAM_PHONE_NUMBER= # Your phone number in international format
TELEGRAM_ALLOWED_GROUPS= # (Optional) Comma-separated list of group usernames (e.g., CryptoTalk,AIDiscussion)
TELEGRAM_SESSION= # Will be auto-generated after first login
To restrict the bot to specific groups:
- Add your bot to the desired Telegram groups
- Set the
TELEGRAM_ALLOWED_GROUPS
variable with the group usernames:TELEGRAM_ALLOWED_GROUPS=CryptoTalk,AIDiscussion,BlockchainHub
- The bot will only respond in these specified groups
- Group usernames are case-sensitive and should match exactly as shown in the invite link (e.g., if the invite link is t.me/MyGroup, use "MyGroup")
- Leave empty to allow the bot to respond in all groups
Run the following command to start Eliza with the CryptoAI Sage character:
pnpm start --characters=characters/cryptoai_sage.character.json
On the first run:
- You'll be prompted to enter your phone number
- Telegram will send you a verification code
- Enter the verification code when prompted
- The session string will be generated save it to .env file to avoid verification each time you run the character file
After the initial setup, you can simply use the same start command:
pnpm start --characters=characters/cryptoai_sage.character.json
- The bot will only respond in groups listed in
TELEGRAM_ALLOWED_GROUPS
- Group usernames must match exactly as they appear in the invite link (e.g., if the invite link is t.me/MyGroup, use "MyGroup")
- You can add or remove groups by updating the
TELEGRAM_ALLOWED_GROUPS
list - If no groups are specified, the bot will not respond to any messages
- You can interact with the bot in both private chats and groups just make sure to mention them in .env
- Use the bot's commands to interact with the CryptoAI Sage character
If you encounter any issues:
- Ensure all environment variables are correctly set
- Check that your API credentials are valid
- Make sure your phone number is in the correct international format
- If the session expires, delete the session string from
.env
and log in again
- Keep your API ID and Hash secure
- Never share your session string
- Regularly review the allowed groups list
- Monitor bot activity in your Telegram account's security settings