Telegram ↔ Claude Code Bridge - Remote control interface for Claude CLI.
Send messages to Claude Code CLI from Telegram and receive responses asynchronously.
- Send messages to Claude from Telegram
- Receive Claude responses with proper markdown formatting
- Typing indicator while Claude processes
- Message chunking for long responses
- Built-in commands (/clear, /stop, /status)
- Retry logic with exponential backoff
- Health monitoring endpoints
Telegram → Cloudflared Tunnel → Node Bridge → tmux → Claude Code
↓
Telegram ← Bot API ← Stop Hook ←──────────────┘
npm installcp .env.example .env
# Edit .env with your bot token and user ID# Start server with tunnel
./bin/start.sh -d -t
# Set webhook
./bin/webhook.sh set --tunnelAdd to ~/.claude/settings.json:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "node /path/to/tg-agent/hooks/send-to-telegram.mjs"
}
]
}
]
}
}| Command | Action |
|---|---|
message |
Send message to Claude |
/reset |
Clear context and return to workspace |
/clear |
Clear Claude screen |
/stop |
Cancel current operation |
/status |
Check bridge status |
/help |
Show commands |
tg-agent/
├── bin/ # Startup scripts
│ ├── start.sh # Service management
│ └── webhook.sh # Webhook management
├── docs/ # Documentation
├── hooks/ # Claude Code hooks
│ └── send-to-telegram.mjs
├── src/
│ ├── server/ # Fastify server
│ ├── telegram/ # Bot API client
│ ├── tmux/ # tmux integration
│ ├── state/ # State management
│ └── utils/ # Utilities
├── logs/ # Log files
└── workspace/ # Working directory
# Start services
./bin/start.sh -d -t # Server + tunnel (daemon)
# Stop services
./bin/start.sh -s
# Check status
./bin/start.sh --status
# View logs
./bin/start.sh --logs- Message @BotFather on Telegram
- Create new bot:
/newbot - Copy token to
.envasTELEGRAM_BOT_TOKEN
- Message @userinfobot on Telegram
- Add your ID to
TELEGRAM_ALLOWED_USERSin.env
- Deployment Guide - Production deployment
- API Reference - Endpoint documentation
# Development server with hot reload
npm run dev
# Type checking
npm run typecheck
# Run tests
npm test
# Run tests in watch mode
npm run test:watch- Node.js 20+
- tmux
- cloudflared (for tunnel)
- Telegram Bot Token
MIT