- Python 3.10+ -- Download here
- Poetry -- Modern Python dependency management
- Telegram Bot Token -- Get one from @BotFather
- Claude Authentication -- Choose one method below
The bot supports two Claude integration modes. Choose the one that fits your needs:
Uses the Python SDK with your existing Claude CLI credentials.
# 1. Install Claude CLI (https://claude.ai/code)
# 2. Authenticate
claude auth login
# 3. Verify
claude auth status
# Should show: "You are authenticated"
# 4. Configure bot
USE_SDK=true
# Leave ANTHROPIC_API_KEY emptyUses the Python SDK with a direct API key, no CLI needed.
# 1. Get your API key from https://console.anthropic.com/
# 2. Configure bot
USE_SDK=true
ANTHROPIC_API_KEY=sk-ant-api03-your-key-hereUses the Claude CLI as a subprocess. Only use for compatibility with older setups.
# 1. Install and authenticate Claude CLI
claude auth login
# 2. Configure bot
USE_SDK=falsegit clone https://github.com/RichardAtCT/claude-code-telegram.git
cd claude-code-telegram
make devcp .env.example .env
nano .envRequired Configuration:
TELEGRAM_BOT_TOKEN=1234567890:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
TELEGRAM_BOT_USERNAME=your_bot_username
APPROVED_DIRECTORY=/path/to/your/projects
ALLOWED_USERS=123456789 # Your Telegram user ID
USE_SDK=true- Message @userinfobot on Telegram
- It will reply with your user ID number
- Add this number to your
ALLOWED_USERSsetting
make run-debug # Recommended for first run
make run # Production- Find your bot on Telegram (search for your bot username)
- Send
/startto begin - Try asking Claude a question about your project
- Use
/statusto check session info
The bot includes an event-driven platform for webhooks, scheduled jobs, and proactive notifications. All features are disabled by default.
Enable to receive external webhooks (GitHub, etc.) and route them through Claude:
ENABLE_API_SERVER=true
API_SERVER_PORT=8080-
Generate a webhook secret:
openssl rand -hex 32
-
Add to your
.env:GITHUB_WEBHOOK_SECRET=your-generated-secret NOTIFICATION_CHAT_IDS=123456789 # Your Telegram chat ID for notifications -
In your GitHub repository, go to Settings > Webhooks > Add webhook:
- Payload URL:
https://your-server:8080/webhooks/github - Content type:
application/json - Secret: The secret you generated
- Events: Choose which events to receive (push, pull_request, issues, etc.)
- Payload URL:
-
Test with curl:
curl -X POST http://localhost:8080/webhooks/github \ -H "Content-Type: application/json" \ -H "X-GitHub-Event: ping" \ -H "X-GitHub-Delivery: test-123" \ -H "X-Hub-Signature-256: sha256=$(echo -n '{"zen":"test"}' | openssl dgst -sha256 -hmac 'your-secret' | awk '{print $2}')" \ -d '{"zen":"test"}'
For non-GitHub providers, use Bearer token authentication:
WEBHOOK_API_SECRET=your-api-secretSend webhooks with:
curl -X POST http://localhost:8080/webhooks/custom \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-secret" \
-H "X-Event-Type: deployment" \
-H "X-Delivery-ID: unique-id-123" \
-d '{"status": "success", "environment": "production"}'Enable to run recurring Claude tasks on a cron schedule:
ENABLE_SCHEDULER=true
NOTIFICATION_CHAT_IDS=123456789 # Where to deliver resultsJobs are managed programmatically and persist in the SQLite database.
Configure which Telegram chats receive proactive notifications from webhooks and scheduled jobs:
NOTIFICATION_CHAT_IDS=123456789,987654321| Feature | SDK + CLI Auth | SDK + API Key | CLI Subprocess |
|---|---|---|---|
| Performance | Best | Best | Slower |
| CLI Required | Yes | No | Yes |
| Streaming | Yes | Yes | Limited |
| Error Handling | Best | Best | Basic |
# Set to a specific project directory, not your home directory
APPROVED_DIRECTORY=/Users/yourname/projects# Whitelist specific users (recommended)
ALLOWED_USERS=123456789,987654321
# Optional: Token-based authentication
ENABLE_TOKEN_AUTH=true
AUTH_TOKEN_SECRET=your-secret-key-hereRATE_LIMIT_REQUESTS=10
RATE_LIMIT_WINDOW=60
RATE_LIMIT_BURST=20
CLAUDE_MAX_COST_PER_USER=10.0DEBUG=true
DEVELOPMENT_MODE=true
LOG_LEVEL=DEBUG
ENVIRONMENT=development
RATE_LIMIT_REQUESTS=100
CLAUDE_TIMEOUT_SECONDS=600# Check your bot token
echo $TELEGRAM_BOT_TOKEN
# Verify user ID (message @userinfobot)
# Check bot logs
make run-debugSDK + CLI Auth:
claude auth status
# If not authenticated: claude auth loginSDK + API Key:
# Verify key starts with: sk-ant-api03-
echo $ANTHROPIC_API_KEY# Check approved directory exists and is accessible
ls -la /path/to/your/projectsENVIRONMENT=production
DEBUG=false
LOG_LEVEL=INFO
RATE_LIMIT_REQUESTS=5
CLAUDE_MAX_COST_PER_USER=5.0
SESSION_TIMEOUT_HOURS=12
ENABLE_TELEMETRY=true- Documentation: Check the main README.md
- Configuration: See configuration.md for all options
- Security: See SECURITY.md for security concerns
- Issues: Open an issue