Overview
Telegram Gateway is a bidirectional bridge between the gmsg messaging system and Telegram. Allows Claude Code agents to send/receive Telegram messages via the gmsg interface.
The problem: AI agents work autonomously, often for hours. When an agent needs input, encounters a blocker, or completes a major task, thereβs no way to notify the human immediately. Users have to manually check agent terminals or message logs to know what happened.
The solution: Telegram Gateway bridges gmsg (agent messaging) and Telegram (human messaging). Agents send messages through gmsg tagged for βTelegramβ delivery, and the gateway forwards them to your Telegram account. You reply in Telegram, and the message routes back to the agentβs gmsg inbox.
Key Features
- Telegram Bot Integration - Send and receive via Telegram Bot API
- Message Format Translation - gmsg β Telegram format conversion
- User Authentication - Verify Telegram users before accepting messages
- Real-Time Notifications - Instant push notifications from agents β mobile
- Command Interface - Send commands to agents from Telegram (start, stop, query status)
- Systemd Service - Production deployment as background service
Use Cases
Long-Running Task Notifications
Agent works overnight on a refactoring task. When complete (or when blocked), sends notification to your phone.
Mobile Agent Monitoring
Check agent fleet status from anywhere. Send command via Telegram: βStatus report, all agents.β Get instant summary.
Urgent Blockers
Agent encounters error it canβt resolve. Sends Telegram message: βDeploy script failed: permission denied on /var/www. Need sudo access?β You respond from mobile, agent continues.
Remote Task Triggering
Youβre away from desk. Send Telegram command: βEE, review the latest PR and report findings.β EE agent starts work, reports back via Telegram when done.
Team Coordination
Multiple humans monitoring agent fleet. Agents broadcast progress updates to Telegram group. Team sees whatβs happening in real-time.
Architecture
ββββββββββββββββββββββββββββββββ
β Claude Code Agents β
β β
β ββββββββββ ββββββββββ β
β βAgent EEβ βAgent MMβ β
β βββββ¬βββββ βββββ¬βββββ β
β β β β
ββββββββΌββββββββββββββΌββββββββββ
β β
ββββΌββββββββββββββΌβββ
β gmsg Server β
βββββββββββ¬ββββββββββ
β
βββββββββββΌββββββββββ
β Telegram Gateway β
β β
β βββββββββββββββββ β
β β Format β β
β β Translation β β
β βββββββββ¬ββββββββ β
βββββββββββΌββββββββββ
β
βββββββββββΌββββββββββ
β Telegram Bot API β
βββββββββββ¬ββββββββββ
β
ββββββββΌβββββββ
β Your Phone β
β (Telegram) β
βββββββββββββββ
Message Flow
Agent β Human:
- Agent sends gmsg message with
receiver="telegram" - Gateway polls gmsg for telegram-tagged messages
- Gateway translates to Telegram format
- Telegram Bot API delivers to your phone
Human β Agent:
- You send Telegram message to bot
- Gateway receives via Telegram Bot API webhook
- Gateway translates to gmsg format
- gmsg routes message to target agentβs inbox
Configuration
# telegram_gateway_config.yaml
telegram:
bot_token: "YOUR_BOT_TOKEN"
allowed_users:
- telegram_user_id: 123456789
name: "Your Name"
gmsg:
server: "unix:/tmp/gmsg.sock"
polling_interval: 5 # seconds
routing:
default_agent: "EE" # Default recipient if not specified
broadcast_to_telegram: true # Forward agent broadcasts
Message Format Examples
Agent notification:
π€ Agent EE
β
Task Complete
Refactoring complete:
- 47 files updated
- All tests passing
- PR ready for review
Next: Await human review
Agent blocker:
π€ Agent MM
β οΈ Blocker
Cannot publish blog post:
Dev.to API returned 403 Forbidden
Possible cause: API key expired?
Need: New API key or permission check
Status query response:
π€ Agent Fleet Status
EE: Active (52% context)
MM: Idle
Brand_Manager: Active (68% context)
MacR: Not running
Active tasks:
- EE: Homepage redesign review
- Brand_Manager: Product descriptions
What Makes It Different
vs. Email Notifications:
- Real-time - Instant push, not polling
- Two-way - Reply directly to agents
- Mobile-native - Telegram optimized for mobile
vs. Slack/Discord Bots:
- Agent-aware - Built for AI agent communication patterns
- gmsg integration - Native to SW2 infrastructure
- Lightweight - No workspace overhead
vs. SMS:
- Rich formatting - Code blocks, markdown, multi-line
- Free - No per-message costs
- Command interface - Send structured commands, not just text
Tech Stack
- Python - Gateway service
- python-telegram-bot - Telegram Bot API client
- gmsg - Message broker integration
- systemd - Production deployment
- YAML - Configuration
Status
Production β Deployed as systemd service, actively used for remote agent monitoring at Silver Wizard Software.
Internal Infrastructure: Telegram Gateway is production infrastructure developed for remote monitoring of SW2βs agent fleet. Available for licensing to organizations building agentic systems.
Security Considerations
- Bot token - Keep secure, donβt commit to repos
- User authentication - Whitelist allowed Telegram user IDs
- Message sanitization - Strip sensitive data before forwarding
- Rate limiting - Prevent spam to agents or Telegram API
- SSL/TLS - Telegram Bot API uses HTTPS
Best Practices
- Tag messages clearly - Use
receiver="telegram"in gmsg - Format for mobile - Short lines, clear structure, emojis for status
- Use commands sparingly - Telegram β agent commands should be high-level
- Test bot locally first - Use Telegramβs BotFather test environment
- Monitor gateway logs - Watch for failed deliveries or API errors
Deployment
# Install as systemd service
sudo cp telegram-gateway.service /etc/systemd/system/
sudo systemctl enable telegram-gateway
sudo systemctl start telegram-gateway
# Check status
sudo systemctl status telegram-gateway
# View logs
sudo journalctl -u telegram-gateway -f
Licensing
Telegram Gateway is internal production infrastructure available for licensing to organizations building multi-agent AI systems with remote monitoring needs.
Contact: silver.wizard001@proton.me for licensing inquiries.
Documentation
- Getting Started Guide
- Bot Setup (BotFather)
- Message Format Specification
- Command Interface
- Deployment Guide
Support
- GitHub: https://github.com/SilverWizardAI/telegram-gateway (in MM repo)
- Email: support@silverwizard.dev
- Licensing: silver.wizard001@proton.me