The Telegram Account Plugin allows ElizaOS agents to connect and operate through a real Telegram account, enabling your agent to participate in Telegram chats, groups, and direct messages as a regular user.
- Connect to any Telegram account using API credentials
- Receive and respond to direct messages
- Participate in group chats when mentioned (@username)
- Reply to messages that reply to the account
- Support for multi-part messages (automatically splits long messages)
- Proper Markdown formatting in responses
- Media attachment support
Before using this plugin, you need:
- A Telegram account with an active phone number
- Telegram API credentials (App ID and App Hash)
- ElizaOS installed and configured
- Visit https://my.telegram.org/apps
- Log in with your Telegram account phone number
- Create a new application if you don't have one already
- Note down the App api_id and App api_hash
Add the following environment variables to your ElizaOS configuration:
TELEGRAM_ACCOUNT_PHONE="+1234567890" # Your phone number with country code
TELEGRAM_ACCOUNT_APP_ID=12345 # Your Telegram API app_id
TELEGRAM_ACCOUNT_APP_HASH="your_api_hash_here"
TELEGRAM_ACCOUNT_DEVICE_MODEL="Desktop" # Device model to show in Telegram
TELEGRAM_ACCOUNT_SYSTEM_VERSION="1.0" # System version to show in Telegram
To install the plugin to your ElizaOS agent:
npm install @elizaos-plugins/client-telegram-account
Add the Telegram Account client to your agent's configuration:
{
"clients": [
"telegramAccount"
]
}
When running your agent for the first time with this plugin:
- The plugin will prompt you to enter the authentication code sent to your Telegram account
- Enter the code to authenticate your session
- The session will be saved for future use
Once configured, your agent will:
- Respond to direct messages automatically
- Respond in groups when specifically mentioned with @username
- Respond to replies to its own messages
- Process incoming media files
- Format responses using Markdown
- Split long messages into multiple parts if necessary
Environment Variable | Required | Description |
---|---|---|
TELEGRAM_ACCOUNT_PHONE |
Yes | Phone number with country code |
TELEGRAM_ACCOUNT_APP_ID |
Yes | Telegram API application ID |
TELEGRAM_ACCOUNT_APP_HASH |
Yes | Telegram API application hash |
TELEGRAM_ACCOUNT_DEVICE_MODEL |
Yes | Device model shown to other users |
TELEGRAM_ACCOUNT_SYSTEM_VERSION |
Yes | System version shown to other users |
- Store your Telegram API credentials securely as they provide full access to your account
- The plugin stores the authentication session in
./data/telegram_account_session
directory - Be mindful of rate limits and Telegram's terms of service
If you encounter authentication problems:
- Make sure your app ID and hash are correct
- Delete the session file in
./data/telegram_account_session
to reset authentication - Ensure your phone number is in the correct format (with country code)
If your agent is not responding properly:
- Check if the agent has the correct username in Telegram
- Verify the agent is being mentioned properly in groups with @username
- Examine the logs for any error messages
- The agent can only respond, it cannot initiate conversations
- In groups, it requires an explicit mention (@username) to respond
- Cannot currently handle voice messages or stickers