opencode-dispatch is a secure Telegram bridge for the opencode CLI. It brings the power of a 120K-star, self-hosted AI agent to your pocket—giving you "Dispatch-style" remote access without the corporate subscription or vendor lock-in.
While the industry moves toward closed, subscription-based mobile interfaces, opencode-dispatch stays true to the open-source ethos: Your models, your hardware, your data.
- 📱 Remote Autonomy: Manage codebases, run tests, and refactor files from a Telegram chat.
- 🤖 Model Agnostic: Connect to 75+ providers via Models.dev or run entirely local via Ollama.
- 🔒 Security First: Built-in Telegram Chat ID locking and context isolation.
- ⚡ Lightweight: Runs on a $5 VPS or your local machine with minimal overhead.
This repository is more than a bridge; it's a foundational layer for a persistent, autonomous agent ecosystem. We are moving beyond stateless terminal commands toward an agent that:
- Remembers: Persistent cross-session context.
- Acts: Scheduled task execution and background monitoring.
- Learns: A plug-and-play skills and personality registry.
- opencode CLI installed — verify with
opencode --version - A Telegram account
- Python 3.10+ or Node.js
- A Telegram bot token (free from @BotFather)
- Open Telegram and search for @BotFather
- Send
/newbotand follow the prompts to get your token.
Choose Python or Node.js (both work the same):
Python:
pip install -r requirements.txtNode.js:
npm installcp .env.example .envEdit .env and add your Telegram bot token:
TELEGRAM_BOT_TOKEN=your_bot_token_here
OPENCODE_API_URL=http://127.0.0.1:5050cd ~/your-project
opencode serve --port 5050Important: Always
cdinto a specific project folder first. This limits opencode's access to that folder and its subfolders.
- Python:
python bot.py - Node.js:
npm start
| Command | Description |
|---|---|
/start |
Welcome message and server info |
/status |
Server health, session ID, queue size |
/working |
Check what task is currently being processed |
/clear |
Clear pending messages from queue |
Never run from your home directory (~) or root (/). opencode can access all files in the directory it's started from.
Set a password to prevent unauthorized local access:
OPENCODE_SERVER_PASSWORD=your-secret opencode serve --port 5050Then add to .env:
OPENCODE_SERVER_PASSWORD=your-secretTo lock the bot so only YOU can use it:
- Get your chat ID from @userinfobot
- Add to
.env:
TELEGRAM_ALLOWED_CHAT_ID=your_chat_id_here"Can't connect to opencode"
- Make sure
opencode serve --port 5050is running in a terminal - Verify with:
curl http://127.0.0.1:5050/global/health
"Bot isn't responding"
- Check your Telegram bot token in
.env - Make sure the bot is running (
python bot.pyornpm start)
"Port already in use"
- Pick a different port:
opencode serve --port 5051 - Update
OPENCODE_API_URLin.envto match
"opencode command not found"
- Install:
curl -fsSL https://opencode.ai/install | bash - Then run:
source ~/.zshrc
Found a bug? Have an improvement? Open an issue or submit a pull request!
MIT