Control OpenCode from Telegram. Your AI coding assistant in your pocket β switch projects, resume and attach to live coding sessions, stream answers with diffs, queue follow-ups, and run it 24/7 as a background service on Windows, Linux, and macOS.
A professional Telegram bridge that drives OpenCode over the Agent Client
Protocol (ACP) β opencode acp via JSON-RPC/stdio β and turns it into a
mobile, always-on AI pair programmer. Send a message from anywhere, and watch
OpenCode plan, read files, run commands, and edit code on your machine β with
live typing indicators, clean Telegram markdown, unified edit diffs, and rich
tool-call visibility.
A fork of artickc/kiro-telegram-bot,
re-architected for OpenCode ACP and extended into a full multi-session client.
| Capability | What it does |
|---|---|
| π Projects | /projects browses your folders and runs OpenCode in the one you pick. |
| β»οΈ Resume sessions | /sessions lists recent OpenCode sessions; tap to resume one. |
| π’ Connect to live sessions | /active shows sessions running right now on your PC. Watch them live, or continue them β see below. |
| π Kill a session / PID | Each live /sessions Β· /active card has a π Kill Β· pid N button (confirm-guarded) that stops that session's process and its child tree; /killall stops them all. The bot's own agent is never killable. |
| π‘ Live watch | Follow a running session read-only in real time (tails its event log). |
| π§ Always-visible menu | A persistent keyboard plus a pinned status panel that appears while a task runs (and clears when idle), showing your current project, agent, reasoning, model, session and queue. |
| β° Scheduled tasks | Create prompts that run on a schedule (once / daily / weekly / monthly / every-N-minutes) in a chosen project, delivered back to your chat. |
| πΌ Multi-image prompts | Send one or many photos (albums included) with a caption β all attached to the prompt for the agent to analyze. |
| π History | /history shows the latest messages of any session. |
| π§© MCP control | /mcp lists MCP servers, health-checks them (which connected / failed and why), and enables/disables them β then restarts the agent to apply. |
| π₯ Subagent visibility | When OpenCode delegates to subagents and waits on them, you see each one start / work / finish plus a live π€ N running summary. |
| π Rich tool-call detail | Every tool kind gets its own formatted card: searches (pattern + scope + filters), reads (path + line/offset), edits (diff blocks with stats), writes (content preview + syntax highlighting), deletes, moves (source β dest), shell commands (bash blocks), fetches (URL + method + body), web searches, MCP calls (server + method + args). |
| β Tool status tracking | See β³ β β or β for each tool call as it completes. |
| π Task progress bar | The agent appends a {progress: N%} marker; the bot hides it and shows a green 0β100% loading bar on the live message, in the status panel, and on session cards (SHOW_PROGRESS). Falls back to a bot-computed bar when the agent doesn't emit markers. |
| π¬ Cost & usage | The β
Done line and /usage show cost used, turns this session, and provider info. |
| β¨οΈ Typing indicator | Stays on for the whole turn, even through long tool chains. |
| π₯ Queued follow-ups | Message while OpenCode is busy β it's queued and runs next. /btw runs it ASAP (now if idle, else right after the current task); /flush runs the queue now. |
| βοΈ Edit diffs | File edits show as unified diff blocks with +N -M stats, smart-truncated for long changes. |
| π¬ Quality markdown | Converts agent markdown to Telegram MarkdownV2 with safe escaping and code-fence-aware splitting. |
| π Self-healing | Auto-restarts the OpenCode agent with backoff and re-binds your session. Auto-fork on context-full, transient-error retry with backoff. |
| π₯ Runs 24/7 | 1-click install as a background service that starts on boot β Windows, Linux, macOS, auto-detected. |
| π Access control | Restrict to specific Telegram user IDs. |
| π Inline approvals | Approve/deny risky tool calls from Telegram buttons (non trust-all mode). |
| π· Threaded replies | Every message threaded to your prompt with searchable hashtags. |
| π§Ή Self-cleaning UI | Transient menus auto-remove for a tidy chat history. |
| π Auto-update | Checks hourly, updates when idle. |
| π File ingestion | Send documents for the agent to read. |
| π Voice messages | Transcribe voice to prompts (configurable STT endpoint). |
| Capability | This bot | Other OpenCode Telegram bots |
|---|---|---|
| Connect OpenCode to Telegram (ACP) | β | β |
| Switch between projects | β | β |
| Resume saved sessions | β | β |
| Attach to live PC sessions (watch / fork) | β | β |
| Kill a session by PID (or all at once) | β | β |
| Rich tool-call detail (search/read/edit/write/delete/move/shell/fetch/MCP) | β | β |
| Tool status tracking (β³ β β / β) | β | β |
| Subagent visibility | β | β |
Live task-progress bars ({progress: N%}) |
β | β |
| Multiple isolated sessions | β | β |
| Queued follow-ups while busy | β | β |
| Scheduled tasks (cron-like) | β | β |
| Multi-image prompts (albums) | β | β |
| Unified edit diffs (smart-truncated) | β | β |
| Persistent menu + live status panel | β | β |
| Agent / reasoning / model menus | β | β |
| Combined, throttled output (no spam) | β | β |
| Auto-restart + session re-bind | β | β |
| 24/7 cross-platform service | β | β |
| 1-click install | β | β |
The fastest way β one command installs the global opencode-tg CLI (ships with
the tsx runtime, no build step):
npm install -g @artickc/opencode-telegram-botBy default your config lives in a canonical, path-independent home β
~/.opencode/tg/ (its .env, logs/, data/) β so the bot loads the same
.env no matter which folder you start it from. Run opencode-tg setup --path to
print the exact location. (A .env in the current folder is still honoured
first, so existing per-folder checkouts keep working.)
opencode-tg setup # auto-detects opencode, writes ~/.opencode/tg/.env
opencode-tg setup --path # print the .env location
# edit that .env: set TELEGRAM_BOT_TOKEN and ALLOWED_USERS
opencode-tg run # foreground β¦
opencode-tg install # β¦ or install as a 24/7 background serviceThe bot is single-instance per token: starting it again terminates any
ghost/duplicate that was still polling Telegram (the usual cause of a stale
"β Not authorized"), so the fresh process with your current .env wins. A
plain opencode-tg run yields to an already-running background service instead.
Startup options: opencode-tg setup [--path] | run | install | status | logs [n] | stop | restart | uninstall. Or try it without installing: npx @artickc/opencode-telegram-bot setup. See docs/INSTALL.md for the
full guide.
Already installed? See docs/UPGRADE.md to update to
the newest version β global npm installs auto-update when idle, or run
npm install -g @artickc/opencode-telegram-bot@latest and opencode-tg restart.
Clone or download, then run the installer for your OS. It installs
dependencies, auto-detects opencode, writes .env, asks for your bot token,
and optionally sets up the background service.
Windows β double-click install.cmd (or in a terminal):
.\install.cmdLinux / macOS:
chmod +x install.sh && ./install.sh- OpenCode installed and configured β run
opencode --versionto confirm. - Node.js 20+.
- A bot token from @BotFather.
- Your Telegram user ID from @userinfobot.
β οΈ Use a dedicated bot token. Telegram allows only one long-polling consumer per token. If you also run another Telegram bot on the same token, they will clash ongetUpdates.
npm install
npm run setup # auto-detects opencode + project roots, writes .env
# edit .env: set TELEGRAM_BOT_TOKEN and ALLOWED_USERS
npm startNo build step β TypeScript runs directly via tsx.
The bot installs as a user-level service that starts automatically on boot. The platform is auto-detected:
| OS | Mechanism | Starts on |
|---|---|---|
| Windows | Hidden Scheduled Task (elevated) Β· per-user Startup folder (no admin) | logon |
| Linux | systemd user service (+ linger) | boot |
| macOS | launchd LaunchAgent | login |
On Windows, registering a logon-triggered Scheduled Task needs admin, so from a
normal terminal opencode-tg install falls back to a hidden launcher in your
per-user Startup folder (starts at logon, no elevation). Run it from an
elevated terminal to use the Scheduled Task instead; either way status,
stop, restart and uninstall work the same.
npm run install:service # install + start, enable autostart
npm run service -- status # show install + running state
npm run service -- stop
npm run service -- restart
npm run service -- logs 200 # tail the log file
npm run uninstall:service # stop + removeOr use the opencode-tg command (if linked): opencode-tg install | status | logs.
Logs are written to logs/opencode-telegram-bot.log (rotated at 5 MB).
/menu Show the persistent menu keyboard
/projects List Β· /projects <q> search Β· /projects <path> open any folder Β· /projects new <name>
/sessions List & resume sessions (active first) Β· /sessions <q> to filter
/active Sessions running now on the PC
/running Sessions this chat controls β switch between them
/killall Kill all active sessions on the PC (with confirm)
/mcp Inspect MCP servers Β· health-check Β· enable/disable
/tasks Manage scheduled tasks
/newtask Create a scheduled task (wizard)
/history Show recent conversation history
/new Start a fresh session here
/status Current session, project & queue
/usage Provider info & current context usage
/btw <text> Run it now if idle, else queue to run right after the current task
/flush Send queued follow-ups now
/queue Show queued follow-ups
/clearqueue Clear the queue
/cancel Stop the current turn
/unwatch Stop following a live session
/model <id> Switch the model for this session
/restart Restart the OpenCode agent
/help Show help
Anything that isn't a command is sent to OpenCode as a prompt. While a turn is running, your messages are queued and sent automatically when it finishes.
A tiny persistent bar sits under the message box β β° Menu Β· π§ Running Β·
βΉ Stop β so common actions are one tap away without clutter. Tap β° Menu
(or /menu) to open a clean, grouped inline menu: Project Β· New Β· Running Β·
Sessions Β· Agent Β· Model Β· Reasoning Β· Tasks Β· Status Β· Usage Β· Stop Β· Kill all.
The bar can be hidden (π) and restored (β¨οΈ Show bar or /menu).
While a task is running, a pinned status panel appears at the top of the chat showing your current task progress, activity, queue, project, session, context %, agent, reasoning effort and model (and how many sessions the chat controls), updating live β and it's removed when the session goes idle so the chat stays clean between tasks (use Status in the menu to see it on demand any time). Pick Agent, Reasoning or Model from the inline menu (reasoning steers how thoroughly the agent works: Minimal β Max).
A task is a prompt + a project + a schedule. When it fires, the bot opens a session in that project, runs the prompt, and delivers the result to your chat.
- /newtask (or the β button) launches a guided wizard: name β prompt β project β schedule β confirm.
- Schedules:
onceat a date/time,dailyat HH:MM,weekly(e.g.Mon 09:00),monthly(e.g.15 09:00), orinterval(every N minutes). - /tasks lists everything with buttons to run now, enable/disable, edit (rename, prompt, project, reschedule) and delete.
Tasks are stored in data/tasks.json and survive restarts; the scheduler runs
them whether you're online or not (great with the 24/7 service).
Send one or several photos β including a Telegram album β with an optional caption. The bot downloads them and attaches them all to the prompt as image content blocks, so the agent can analyze them together. Images sent while OpenCode is busy are queued with your next turn.
Images come back too: when the agent produces images during a turn (e.g.
takes screenshots while testing an app), the bot detects the freshly-written
files and sends them back to Telegram automatically (SEND_AGENT_IMAGES).
Send a voice note (or audio file) and the bot transcribes it and runs it as a
prompt. Configure any OpenAI/Whisper-compatible endpoint via STT_API_URL in
.env; leave STT_LANGUAGE blank for automatic detection (English, Russian,
Romanian/Moldovan, and ~100 more).
Send any document and the bot resolves it. Text-like files β a long
message your Telegram client turned into a .txt, plus code, logs, JSON, CSV,
Markdown, and more β are downloaded, decoded, and inlined into the prompt (up to
DOC_MAX_CHARS, then truncated with a note), so the agent reads the whole thing.
Binary files are saved under <data>/downloads and their path is handed to
the agent to open with its own tools. An optional caption becomes the
instruction; files sent while OpenCode is busy are queued with your next turn.
Reply to any message (yours or the bot's) and the referenced content rides along with your new message, so a terse "fix this" or "why?" keeps its meaning. If you highlight a specific quote while replying, the bot forwards that exact excerpt plus the surrounding message. Works for text, photo, voice and file prompts alike (long quotes are trimmed to keep prompts lean).
The bot asks the agent to end each message with a {progress: N%} marker, then
hides the marker and renders a green loading bar from 0β100 %
(π©π©π©π©π©β¬β¬β¬β¬β¬ 50%, all-green β
at 100 %) so you can see how far along the
current task is. The bar appears at the bottom of the live message, in the
pinned status panel, and on /running and /sessions cards. Markers are
also stripped from history, replays and previews, so the raw plumbing never
shows. Turn it off with SHOW_PROGRESS=false.
That marker is only an instruction the model can ignore β weaker/free models and
long, tool-heavy turns often emit none, which used to leave the bar empty for the
whole turn. So when SHOW_PROGRESS is on but no marker arrives, the bot falls
back to a computed bar derived from real activity (completed tool calls,
streamed output, elapsed time): it starts low, climbs as work advances, and fills
to 100 % when the turn completes. The agent's own marker, when present, always
takes precedence and the value never decreases. Disable the fallback with
PROGRESS_FALLBACK=false.
One chat can drive multiple OpenCode sessions and switch between them. Start
a session (π Project / π New), and each becomes a "controlled" session. Tap
π§ Running (or /running) to switch: the foreground session streams live
while the others keep working quietly. When you switch to a session you see its
recent context and every message that arrived while you were away (its
unread, recovered from the session log). Leave a task running in A, hop to B,
reply, and come back to A to read what it did. Close a session with β (it isn't
killed) β or tap π Kill Β· pid N on its /sessions Β· /active card to stop
its process (and /killall to stop them all).
While a turn is running, the bot marks that session busy (a .lock with the live
child's pid), so a second turn can't collide with it. You can still:
- π‘ Watch β follow the running session's output live (read-only) by tailing
its event log. Stop with
/unwatch. - Continue (fork) β tapping a live session opens a linked continuation in the same project, primed with the recent transcript, so you can keep interacting from Telegram without disturbing the running turn.
Resuming an idle session loads it directly so you continue the exact thread.
| Variable | Required | Default | Description |
|---|---|---|---|
TELEGRAM_BOT_TOKEN |
yes | β | Bot token from @BotFather. |
ALLOWED_USERS |
recommended | (all) | Comma-separated Telegram user IDs. Empty = anyone (unsafe). |
OPENCODE_PATH |
no | auto / opencode |
Path to the opencode binary. |
OPENCODE_WORKSPACE |
no | cwd | Default working directory. |
OPENCODE_AGENT |
no | β | Custom agent from .opencode/agents/. |
OPENCODE_TRUST_ALL_TOOLS |
no | true |
Run tools without prompts. |
PROJECT_ROOTS |
no | workspace parent + home | Roots for /projects. |
STREAM_THROTTLE_MS |
no | 1500 |
Live-edit interval while streaming. |
MESSAGE_BATCH_MS |
no | 800 |
Window to coalesce rapid text messages into one prompt. 0 disables. |
SHOW_TOOL_CALLS |
no | true |
Show tool-call status messages. |
SHOW_EDIT_DIFFS |
no | true |
Show unified diffs for edits. |
DIFF_MAX_LINES |
no | 40 |
Max diff lines shown inline (smart-truncated). |
DOC_MAX_CHARS |
no | 100000 |
Max characters of a text file attachment inlined into the prompt. |
SHOW_SUBAGENTS |
no | true |
Stream subagent start/work/finish while the main agent waits. |
SHOW_PROGRESS |
no | true |
Ask the agent to append a {progress: N%} marker to each message; the bot parses it, hides the marker, and renders a green 0β100% bar. |
PROGRESS_FALLBACK |
no | true |
When SHOW_PROGRESS is on but the agent emits no marker, render a bot-computed bar derived from real activity. |
NOTIFY_OTHER_SESSIONS |
no | true |
Deliver a session's "Done" summary even when it's a background session. |
MCP_PROBE_TIMEOUT_MS |
no | 8000 |
Per-server timeout for the /mcp live health-check. |
MCP_PROBE_CONCURRENCY |
no | 6 |
How many MCP health probes run at once. |
OPENCODE_AUTO_RESTART |
no | true |
Auto-restart the agent if it exits. |
OPENCODE_TG_SINGLE_INSTANCE |
no | true |
Enforce one running bot per token. |
AUTO_UPDATE |
no | true |
Hourly check npm and, when a newer version exists and the bot is idle, auto-update + restart + post the release notes. |
UPDATE_CHECK_MS |
no | 3600000 |
How often to check npm for updates (ms). |
PROMPT_RETRY_ATTEMPTS |
no | 5 |
Max retries for a transient agent error before any output streamed, with 6s β 12s β 24s β 48s β 60s backoff. |
AUTO_FORK_ON_ERROR |
no | true |
When retries are exhausted on a transient error, logically fork the session and retry the message once. |
AUTO_FORK_CONTEXT_PCT |
no | 85 |
When a prompt fails transiently and context usage is at/above this %, skip the retry backoff and fork immediately. |
RESUME_ON_STREAM_ERROR |
no | true |
When a transient error strikes after the reply already began streaming, ask the same session to continue from where it stopped. |
QUIET_NOTIFICATIONS |
no | true |
Send messages silently (no notification sound) except for turn-completing messages. |
LOG_LEVEL |
no | info |
debug | info | warn | error. |
LOG_DIR / LOG_FILE |
no | <project>/logs/β¦ |
Log location. |
See .env.example for the full list with comments.
Telegram ββHTTPSβββΆ Bot (grammY)
β spawns once
βΌ
opencode acp βββ JSON-RPC 2.0 over stdio (ACP) βββΆ Bot
β
ββ initialize (handshake)
ββ session/new Β· session/load (projects, resume)
ββ session/prompt (your messages)
ββ session/update (streamed text, tools)
One opencode acp process multiplexes many sessions. After initialize the
bot runs session/new or session/load, then streamed session/update
notifications are assembled into a live, throttled message and tool_call
updates render as status cards with diffs and completion status.
The bot records the sessions it drives on disk under <data>/sessions/:
<id>.json (metadata), <id>.jsonl (history, used by /history and live
watch), and <id>.lock (written while a turn runs, for active detection).
src/
βββ index.ts Entry point, daemon-friendly logging, shutdown
βββ cli.ts CLI: run / install / start / stop / status / logs
βββ config.ts .env loading, paths, daemon options
βββ logger.ts Leveled logger with file output
βββ opencode/ OpenCode ACP bridge: client, transport, types
βββ sessions/ Session discovery, history parser, live tail watcher
βββ projects/ Project directory discovery
βββ mcp/ MCP config (list/toggle) + live health probe
βββ render/ MarkdownβMarkdownV2, diffs, tool formatting, chunking
βββ stream/ Incremental edit-streaming
βββ service/ Cross-platform daemon (windows/linux/macos + selector)
βββ bot/ grammY bot, per-chat runtime, handlers
Can I run the OpenCode Telegram bot 24/7 on a server? Yes β npm run install:service
installs a user-level service (systemd/launchd/Scheduled Task) that starts on
boot and auto-restarts on crash.
How do I control OpenCode from my phone? Set up the bot, message it on Telegram,
and pick a project with /projects. Every message becomes a prompt.
Can multiple people use one bot? Add their IDs to ALLOWED_USERS. Each chat
gets its own session.
Does it support custom agents and MCP servers? Yes β set OPENCODE_AGENT,
and the bot works with MCP servers configured in OpenCode's config.
When OpenCode asks the client to approve a risky tool call, it appears in Telegram
with Approve / Deny buttons. Set OPENCODE_TRUST_ALL_TOOLS=false to enable
this mode. You can also intervene on any live turn with the tool stream + βΉ Stop
(/cancel), which cancels that session's turn.
This bot lets authorized Telegram users run commands and edit files on the host.
Always set ALLOWED_USERS, keep .env private, and run as a non-privileged
user. See SECURITY.md for the full model.
- Projects, resume & attach to live sessions
- Queued follow-ups, edit diffs, quality MarkdownV2
- Persistent menu + live status panel (project / agent / reasoning / model)
- Scheduled tasks (once / daily / weekly / monthly / interval)
- Multi-image prompts (albums)
- Combined, throttled output (anti-spam)
- 24/7 cross-platform background service
- Voice messages β speech-to-text β prompt (multi-language)
- Context-usage % in the status panel
- Inline approvals β approve/deny risky tools from buttons
- Rich tool-call detail for every kind (search/read/edit/write/delete/move/shell/fetch/MCP)
- Tool status tracking (β³ β β / β)
- Subagent visibility
- Release automation β downloadable zip + CHANGELOG-driven notes on tag push
- README community sections β Contributors, Top Contributors, Stars, StarMapper
- Token & cost meter β per-session token counts and an estimated spend tally
- Text-to-speech replies β optionally speak answers back as voice notes
- Scheduled-task chaining & conditions β run task B after A
- Team mode β multiple authorized users with per-user sessions, roles, and an audit log
- Localized bot UI (i18n)
- Docker image with
opencodepreinstalled - Webhook mode for serverless deployment
Have an idea? Open a feature request.
Contributions are very welcome! See CONTRIBUTING.md to get
started β no build step is required (npm run dev), and npm run typecheck must
pass.
New here? Look for issues labeled good first issue and help wanted.
By participating you agree to the Code of Conduct.
- Fork the repository
- Create your feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
See CONTRIBUTING.md for detailed guidelines.
# Bump the version, update CHANGELOG.md, then push a tag.
# The release workflow builds a downloadable zip and publishes notes automatically.
npm version minor # or: patch / major β updates package.json + commits
git push --follow-tags # pushing the v* tag triggers .github/workflows/release.ymlThis project is built and maintained in the open. These people have made the contributions that shape its quality, stability, and reach. Thank you.
![]() artickc π₯ Maintainer Created the bot: OpenCode ACP bridge, multi-session runtime, scheduler, daemon & renderer |
π Every pull request, bug report, and idea matters. Open source is built by people like them β see the full list under Contributors.
If this project helps you, please consider giving it a β β it really helps!
See where in the world this project's stargazers live β an interactive map of the community.
Grab the latest packaged build from the
Releases page β each
release ships a clean opencode-telegram-bot-<version>.zip (no node_modules or
secrets) plus GitHub's source archives. See CHANGELOG.md for
what changed in each version, docs/INSTALL.md for the
full 1-click install guide, and docs/UPGRADE.md for how
to update an existing install.
MIT β see also CONTRIBUTING and Code of Conduct.
Keywords: OpenCode Telegram bot, AI coding assistant on Telegram, mobile AI pair programming, remote coding agent, run AI agent as a service, Windows/Linux/macOS daemon, ChatOps for developers.








