opencode-telegram-pluginControl OpenCode from your phone via Telegram. Send prompts, manage sessions, run shell commands, approve permissions, and execute any OpenCode slash command.
0
65
14 in 7 days
22.3
Multi-signal model
5 months ago
2026-03-06
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-telegram-plugin@0.1.0"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-telegram-plugin@0.1.0"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-telegram-pluginopencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
Control OpenCode from your phone via Telegram. Send prompts, manage sessions, run shell commands, approve permissions, and execute any OpenCode slash command -- all from a Telegram chat.
Installation
From npm (recommended)
Add to your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-telegram-plugin"]
}
Or install globally in ~/.config/opencode/opencode.json.
OpenCode will automatically install the plugin using Bun.
Manual install
Copy telegram-plugin.ts to your plugins directory:
# Global
cp telegram-plugin.ts ~/.config/opencode/plugins/
# Project-specific
cp telegram-plugin.ts .opencode/plugins/
Then add the dependency to your package.json:
{
"dependencies": {
"node-telegram-bot-api": "^0.66.0"
}
}
Setup
1. Create a Telegram bot
- Open Telegram and search for @BotFather
- Send
/newbotand follow the prompts to name your bot - Copy the bot token BotFather gives you
2. Get your chat ID
- Send any message to your new bot
- Open this URL in your browser (replace
<TOKEN>with your bot token):https://api.telegram.org/bot<TOKEN>/getUpdates - Find
"chat":{"id":XXXXXXXX}in the response -- that number is your chat ID
3. Set environment variables
Add these to your shell profile (~/.zshrc, ~/.bashrc, etc.):
export TELEGRAM_BOT_TOKEN="your-bot-token"
export TELEGRAM_CHAT_ID="your-chat-id"
4. Restart OpenCode
The plugin loads at startup. You'll receive a "Connected!" message in Telegram when it's ready.
Features
- Chat with OpenCode -- send any message as a prompt and get the full response back
- All OpenCode commands -- every built-in and custom slash command is available as
/oc_<name> - Shell commands -- run shell commands with
/shellor the!prefix - Session management -- create, list, switch, and abort sessions
- Permission forwarding -- tool permission requests are forwarded to Telegram with yes/always/no options; reply with YES, ALWAYS, or NO to respond. Auto-denies after 5 minutes
- File diff view -- see what files were changed in the current session
- Auto-discovery -- custom commands defined in
.opencode/commands/oropencode.jsonare automatically registered in the Telegram bot menu at startup - Long message handling -- responses are split to fit Telegram's 4096 character limit
- Error notifications -- session errors are forwarded to Telegram
Commands
Session management
| Command | Description |
|---|---|
/start |
Show help and all available commands |
/new [title] |
Create a new session |
/sessions |
List recent sessions |
/switch <id> |
Switch to a session by ID prefix |
/status |
Show current session info |
/abort |
Abort the running task |
/diff |
Show files changed in the session |
/messages |
Show the last 5 messages |
/commands |
List all available OpenCode commands |
Shell
| Command | Description |
|---|---|
/shell <cmd> |
Run a shell command |
!<cmd> |
Inline shell (e.g. !git status) |
OpenCode built-in commands
All OpenCode slash commands are available with the /oc_ prefix:
| Command | Maps to |
|---|---|
/oc_undo |
/undo -- revert last message and file changes |
/oc_redo |
/redo -- restore undone message |
/oc_compact |
/compact -- summarize/compact the session |
/oc_share |
/share -- share the session |
/oc_unshare |
/unshare -- unshare the session |
/oc_init |
/init -- create or update AGENTS.md |
/oc_models |
/models -- list available models |
/oc_help |
/help -- show OpenCode help |
Custom commands
Any custom commands you define in .opencode/commands/ or your opencode.json config are automatically discovered and registered. For example, if you have a /test command, it becomes /oc_test in Telegram.
Custom commands can accept arguments:
/oc_test --coverage
Permissions
When OpenCode needs permission to execute a tool (file edits, bash commands, etc.), the request is forwarded to Telegram with details about the tool. You can respond by:
- Replying to the permission message with:
YESorY- Approve onceALWAYSorA- Always allow this patternNOorN- Deny
- Sending
YES,ALWAYS, orNOwithout replying (applies to most recent pending request) - Doing nothing - Requests auto-deny after 5 minutes
Use /pending to see any pending permission requests.
Environment variables
| Variable | Required | Description |
|---|---|---|
TELEGRAM_BOT_TOKEN |
Yes | Bot token from @BotFather |
TELEGRAM_CHAT_ID |
Yes | Your Telegram chat ID |
If either variable is missing, the plugin logs a warning and disables itself.
Requirements
- OpenCode v0.1+
- Node.js 18+
node-telegram-bot-apinpm package
License
MIT