linuz90/claude-telegram-bot
About
Turn Claude Code into your personal assistant, accessible from anywhere via Telegram.
Design & MediaWhat you can do
- π¬ Text: Ask questions, give instructions, have conversations
- π€ Voice: Speak naturally - transcribed via OpenAI and processed by Claude
- πΈ Photos: Send screenshots, documents, or anything visual for analysis
- π Documents: PDFs, text files, and archives (ZIP, TAR) are extracted and analyzed
Measured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalClaude Telegram Bot
Turn Claude Code into your personal assistant, accessible from anywhere via Telegram.
Send text, voice, photos, documents, audio, and video. See responses and tools usage in real-time.

Claude Code as a Personal Assistant
I've started using Claude Code as a personal assistant, and I've built this bot so I can access it from anywhere.
In fact, while Claude Code is described as a powerful AI coding agent, it's actually a very capable general-purpose agent too when given the right instructions, context, and tools.
To achieve this, I set up a folder with a CLAUDE.md that teaches Claude about me (my preferences, where my notes live, my workflows), has a set of tools and scripts based on my needs, and pointed this bot at that folder.
β π See the Personal Assistant Guide for detailed setup and examples.
Bot Features
- π¬ Text: Ask questions, give instructions, have conversations
- π€ Voice: Speak naturally - transcribed via OpenAI and processed by Claude
- πΈ Photos: Send screenshots, documents, or anything visual for analysis
- π Documents: PDFs, text files, and archives (ZIP, TAR) are extracted and analyzed
- π΅ Audio: Audio files (mp3, m4a, ogg, wav, etc.) are transcribed via OpenAI and processed
- π¬ Video: Video messages and video notes are processed by Claude
- π Session persistence: Conversations continue across messages
- π¨ Message queuing: Send multiple messages while Claude works - they queue up automatically. Prefix with
!or use/stopto interrupt and send immediately - π§ Extended thinking: Trigger Claude's reasoning by using words like "think" or "reason" - you'll see its thought process as it works (configurable via
THINKING_TRIGGER_KEYWORDS) - π Interactive buttons: Claude can present options as tappable inline buttons via the built-in
ask_userMCP tool - π File delivery: Claude can send files (images, videos, audio, documents) back to the chat via the
send_fileMCP tool
Quick Start
git clone https://github.com/linuz90/claude-telegram-bot
cd claude-telegram-bot
cp .env.example .env
# Edit .env with your credentials
bun install
bun run src/index.ts
Prerequisites
- Bun 1.0+ - Install Bun
- Claude Agent SDK -
@anthropic-ai/claude-agent-sdk(installed via bun install) - Telegram Bot Token from @BotFather
- OpenAI API Key (optional, for voice transcription)
Claude Authentication
The bot uses the @anthropic-ai/claude-agent-sdk which supports two authentication methods:
| Method | Best For | Setup |
|---|---|---|
| CLI Auth (recommended) | High usage, cost-effective | Run claude once to authenticate |
| API Key | CI/CD, environments without Claude Code | Set ANTHROPIC_API_KEY in .env |
CLI Auth (recommended): The SDK automatically uses your Claude Code login. Just ensure you've run claude at least once and authenticated. This uses your Claude Code subscription which is much more cost-effective for heavy usage.
API Key: For environments where Claude Code isn't installed. Get a key from console.anthropic.com and add to .env:
ANTHROPIC_API_KEY=sk-ant-api03-...
Note: API usage is billed per token and can get expensive quickly for heavy use.
Configuration
1. Create Your Bot
- Open @BotFather on Telegram
- Send
/newbotand follow the prompts to create your bot - Copy the token (looks like
1234567890:ABC-DEF...)
The bot registers its / command menu on startup, so there's no need to run /setcommands in BotFather (any list set there is overwritten).
2. Configure Environment
Create .env with your settings:
# Required
TELEGRAM_BOT_TOKEN=1234567890:ABC-DEF... # From @BotFather
TELEGRAM_ALLOWED_USERS=123456789 # Your Telegram user ID
# Recommended
CLAUDE_WORKING_DIR=/path/to/your/folder # Where Claude runs (loads CLAUDE.md, skills, MCP)
OPENAI_API_KEY=sk-... # For voice transcription
# Optional
CLAUDE_MODEL=claude-sonnet-5-5 # Full model ID (default: claude-sonnet-5-5)
Finding your Telegram user ID: Message @userinfobot on Telegram.
File access paths: By default, Claude can access:
CLAUDE_WORKING_DIR(or home directory if not set)~/Documents,~/Downloads,~/Desktop~/.claude(for Claude Code plans and settings)
To customize, set ALLOWED_PATHS in .env (comma-separated). Note: this overrides all defaults, so include ~/.claude if you want plan mode to work:
ALLOWED_PATHS=/your/project,/other/path,~/.claude
3. Configure MCP Servers (Optional)
Copy and edit the MCP config:
cp mcp-config.example.ts mcp-config.ts
# Edit mcp-config.ts with your MCP servers
The bot includes two built-in MCP servers:
ask_userβ Lets Claude present options as tappable inline keyboard buttonssend_fileβ Lets Claude send files (images, videos, audio, documents) back to the chat
Add your own MCP servers (Things, Notion, Typefully, etc.) to give Claude access to your tools.
Bot Commands
| Command | Description |
|---|---|
/start |
Show status and your user ID |
/new |
Start a fresh session |
/resume |
Pick from last 5 sessions to resume (with recap) |
/stop |
Interrupt current query |
/status |
Check what Claude is doing |
/restart |
Restart the bot |
Running as a Service (macOS)
cp launchagent/com.claude-telegram-ts.plist.template ~/Library/LaunchAgents/com.claude-telegram-ts.plist
# Edit the plist with your paths and env vars
launchctl load ~/Library/LaunchAgents/com.claude-telegram-ts.plist
The bot will start automatically on login and restart if it crashes.
Prevent sleep: To keep the bot running when your Mac is idle, go to System Settings β Battery β Options and enable "Prevent automatic sleeping when the display is off" (when on power adapter).
Logs:
tail -f /tmp/claude-telegram-bot-ts.log # stdout
tail -f /tmp/claude-telegram-bot-ts.err # stderr
Shell aliases: If running as a service, these aliases make it easy to manage the bot (add to ~/.zshrc or ~/.bashrc):
alias cbot='launchctl list | grep com.claude-telegram-ts'
alias cbot-stop='launchctl bootout gui/$(id -u)/com.claude-telegram-ts 2>/dev/null && echo "Stopped"'
alias cbot-start='launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.claude-telegram-ts.plist 2>/dev/null && echo "Started"'
alias cbot-restart='launchctl kickstart -k gui/$(id -u)/com.claude-telegram-ts && echo "Restarted"'
alias cbot-logs='tail -f /tmp/claude-telegram-bot-ts.log'
Development
# Run with auto-reload
bun --watch run src/index.ts
# Type check
bun run typecheck
# Or directly
bun run --bun tsc --noEmit
Security
β οΈ Important: This bot runs Claude Code with all permission prompts bypassed. Claude can read, write, and execute commands without confirmation within the allowed paths. This is intentional for a seamless mobile experience, but you should understand the implications before deploying.
β Read the full Security Model for details on how permissions work and what protections are in place.
Multiple layers protect against misuse:
- User allowlist - Only your Telegram IDs can use the bot
- Intent classification - AI filter blocks dangerous requests
- Path validation - File access restricted to
ALLOWED_PATHS - Command safety - Destructive patterns like
rm -rf /are blocked - Rate limiting - Prevents runaway usage
- Audit logging - All interactions logged to
/tmp/claude-telegram-audit.log
Troubleshooting
Bot doesn't respond
- Verify your user ID is in
TELEGRAM_ALLOWED_USERS - Check the bot token is correct
- Look at logs:
tail -f /tmp/claude-telegram-bot-ts.err - Ensure the bot process is running
Claude authentication issues
- For CLI auth: run
claudein terminal and verify you're logged in - For API key: check
ANTHROPIC_API_KEYis set and starts withsk-ant-api03- - Verify the API key has credits at console.anthropic.com
Voice messages fail
- Ensure
OPENAI_API_KEYis set in.env - Verify the key is valid and has credits
Claude can't access files
- Check
CLAUDE_WORKING_DIRpoints to an existing directory - Verify
ALLOWED_PATHSincludes directories you want Claude to access - Ensure the bot process has read/write permissions
MCP tools not working
- Verify
mcp-config.tsexists and exports properly - Check that MCP server dependencies are installed
- Look for MCP errors in the logs
License
MIT
Explore related projects
Loadingβ¦