Skip to content

Conversation

@Ntrakiyski
Copy link

Summary

Adds full Telegram bot integration allowing users to interact with Agent Zero through Telegram messages.

Features

  • Async Telegram bot using python-telegram-bot library
  • User authorization via TELEGRAM_BOT_ALLOWED_USERS secret (comma-separated user IDs)
  • Commands:
    • /start - Show welcome message and available commands
    • /new - Start a fresh conversation (resets context)
    • /id - Show your Telegram user ID (for authorization setup)
  • Long message splitting for Telegram's 4096 character limit
  • 300-second timeout for agent responses with user-friendly error messages
  • Threaded execution with graceful shutdown
  • Hot-reload support when settings/secrets change

Configuration

Required secrets (add in Settings > Secrets):

  • TELEGRAM_BOT_TOKEN - Your bot token from @BotFather

Optional secrets:

  • TELEGRAM_BOT_ALLOWED_USERS - Comma-separated Telegram user IDs allowed to use the bot (e.g., 123456789,987654321)

How to Use

  1. Create a bot via @BotFather on Telegram
  2. Copy the bot token
  3. Add TELEGRAM_BOT_TOKEN=your_token_here to Secrets
  4. (Optional) Add your user ID to TELEGRAM_BOT_ALLOWED_USERS for access control
  5. Enable "Telegram Bot" in Settings > External Services > Telegram Bot

Files Changed

  • python/helpers/telegram_bot.py - Core bot implementation
  • webui/components/settings/external/telegram_bot.html - Settings UI
  • python/helpers/settings.py - Added telegram_bot_enabled setting
  • run_ui.py - Initialize bot on startup
  • webui/components/settings/external/external-settings.html - Navigation link
  • requirements.txt - Added python-telegram-bot>=21.11.1 and wsproto>=1.2.0
  • docker-compose.yml - Docker deployment configuration

Testing

Tested with:

  • Bot creation via BotFather
  • Message handling and agent responses
  • Long message splitting
  • User authorization
  • Commands (/start, /new, /id)
  • Settings hot-reload

🤖 Generated with Claude Code

Add full Telegram bot integration allowing users to interact with Agent Zero through Telegram:

Features:
- Async Telegram bot using python-telegram-bot library
- User authorization via TELEGRAM_BOT_ALLOWED_USERS secret
- Commands: /start (welcome), /new (reset conversation), /id (show user ID)
- Long message splitting for Telegram's 4096 character limit
- 300-second timeout for agent responses
- Threaded execution with graceful shutdown
- Hot-reload support when settings change

Changes:
- New python/helpers/telegram_bot.py - Core bot implementation
- New webui/components/settings/external/telegram_bot.html - Settings UI
- Add telegram_bot_enabled setting to settings.py
- Initialize bot in run_ui.py on startup
- Update external-settings.html with Telegram bot navigation
- Add python-telegram-bot>=21.11.1 to requirements.txt
- Add docker-compose.yml for Docker deployment

Configuration:
- TELEGRAM_BOT_TOKEN secret required
- TELEGRAM_BOT_ALLOWED_USERS secret for access control (optional)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant