Back to projects
A Telegram ↔ Claude Code CLI bridge
Telegram bots

A Telegram ↔ Claude Code CLI bridge

A gateway that turns Telegram into a full interface to Claude Code: sessions, action streaming, files, and interactive buttons.

Challenge. I needed access to Claude Code CLI straight from a messenger — with context preserved between messages, no lost sessions, and a live view of what the agent is doing.

Approach. I built not an "API wrapper" but a full bridge to the claude process: a message queue, process lifecycle management, and streaming of intermediate steps.

Solution. Node.js + grammY, queued routing (parallel across sessions, sequential within one), context persistence via claude -p --resume, stream-json parsing to show intermediate actions (file reads, command runs), interactive questions and plan approvals via inline buttons, and file exchange through [file:] and [photo:] tags. State lives in PostgreSQL, with self-update validated (syntax, ESLint, tests) before restart and stale processes cleaned up by a systemd timer.

Result. This bot is what you're talking to me through right now. Stable operation across several parallel sessions, no context loss, transparent output of every step, and safe self-updates.

Related work