PlayThe Telegram bridge
My own Telegram bridge.
I started with OpenClaw in January. When I later wanted to work with Codex and Claude Code from my phone, their remote options didn’t fit how I worked. I built my own bridge so I could stay in Telegram and choose both the model and the agent program that would do the work.
In short, without the jargon
I built a bridge between the chat app Telegram and the programs on my computer. From my phone, I can choose which AI model and which program picks up the work. I can send text, images, and files and get replies and results in the same place. The chosen program decides which tools the assistant can use.
Room to switch models.
I mainly work with frontier models. The models I use most change as I try them on my own tasks. That’s why I’ve built my setup so I can easily switch models and agent tools, including from my phone through my Telegram bridge.
A screenshot as a bug report.
I still prefer my own bridge because I can change it myself. When something goes wrong, the quickest way for me to get a fix is often a screenshot in the chat I already have open. In the Codex remote interface, I’ve seen parts of a conversation or reply disappear from my view. I want a say in how progress, replies, and files show up in my chat.
Show the problem
When I spot a bug in my own bridge, I send a screenshot in Telegram and say what I expected to see. The image and caption can go to an agent that understands images and can work in the relevant project.
Trace it into the code
In the same thread, I can ask the agent to find the code that formats the message or handles a button. If I ask for a fix, it can change the code, run a relevant test, and report what the test showed.
Try it again in Telegram
Once the change is in use, I repeat the action on my phone. That’s when I can tell whether the result on the screen is right, too.
Where does my message go?
My phone talks to Telegram. On my computer, a Node.js process translates Telegram messages into the format the selected agent program understands. It also handles the return trip.
- Chat and topic
- The combination of Telegram chat and forum topic points to a saved agent session. On the first Codex turn, the bridge starts a CLI session and saves its ID. With the next message, it uses that ID to resume the session.
- Queue and interruption
- While a topic is busy, text and photos can wait in a bounded first-in, first-out queue. “Steer nu” (steer now) stops the current local turn and moves a selected message to the front. “Fjern” (remove) takes it out of the queue. Photo albums are collected into one turn with the photos in order. Documents and voice notes need an idle topic.
- Events and replies
- The adapter returns commentary, tool events, and a final reply. The bridge can show progress as it happens and buffer the final text before formatting it for Telegram. It can also send a result file back to my phone.
Which parts can I swap?
The bridge is both model- and harness-agnostic. A harness is the program that manages an agent’s session, tools, and execution. Each supported harness has an adapter so I can switch programs and keep using Telegram.
- Agent program
- The current bridge can dispatch agent work to Codex CLI or OpenCode. My earlier Claude Code bridge was a separate integration. Switching backends keeps me in the same Telegram chat and starts a separate conversation history on the new backend.
- Model and provider
- I can choose among the models and providers each adapter supports. The Together adapter provides text-only chat through an API. A full agent can also work with the project’s files and tools within the access I’ve granted it.
- Device, editor, and project
- I can open Telegram on a phone, tablet, computer, or the web. The work can live in different project directories, and I don’t need a particular editor on the device I’m writing from. The bridge itself runs on its host and uses Telegram as its transport. The current macOS setup uses a LaunchAgent.
Voice and files in both directions.
I can send a voice note, transcribe it with local Whisper, and pass the text to an agent as a task. Local Supertonic can read a reply aloud. Photos, albums, and documents have their own handling. The selected adapter determines which kinds of media the agent can actually use. The private bot accepts only my authorized account.
See the five Telegram reactions in the Thinking LibraryWhat can I control from Telegram?
The bot menu has 26 entries. I use 13 commands to control the bridge and 13 shortcuts to call on an agent’s skills. Here’s what each one does in my private chat.
The 13 bridge commands
/new- Start a fresh model conversation in this Telegram topic after the active work finishes or stops.
/cd- Choose this topic’s project directory. Two topics can work in different projects.
/model- Choose an available model and route through Codex, OpenCode Go, or Together. Each provider has its own conversation state.
/think- Choose the reasoning effort from the levels the selected model supports.
/capabilities- Inspect the Codex account’s model and feature catalog. /capabilities refresh retrieves a fresh listing. sync and opdater are aliases for refresh.
/status- Inspect the session, working directory, CLI status, and network and browser preflight. A task’s own result shows whether it succeeded.
/show- Choose which commentary and tool events appear in the chat, or show only the final reply.
/queue- List queued text messages and photos. /queue clear clears the queue. ryd and tøm are Danish aliases for clear.
/stop- Interrupt the active model turn. This also pauses a running bridge goal. Pending messages stay in the queue.
/goal- Have the bridge manage a task across turns. Its subcommands are status, pause, resume, stop, and clear. The bridge tracks this loop independently of Codex’s native goals.
/sendfile- Specify a local result file to send back as a Telegram document.
/usage- Inspect the topic’s token and usage metadata where available. The provider’s billing record is the source for the final charge.
/trace- Inspect metadata for a run in the bridge’s experimental log, Run Ledger. /trace useful and /trace miss record feedback on a run. A miss can be categorized as wrong, context, slow, tool, format, or other.
Two more names, /start and /help, open help. /cost is another name for /usage. The bridge also recognizes a few exact phrases. The Danish “stop nu” stops the active turn, and “er du der” checks whether the bridge is responding.
13 skill shortcuts
A shortcut such as /full_stack_e2e_review becomes a request for that named skill in the agent. The selected agent needs the skill installed and available. The Together route supports text-only chat.
/imagegen- Generate or edit an image.
/search- Search the web for sources.
/fetch- Retrieve content from a URL.
/browser- Work in an interactive browser.
/openai_docs- Consult OpenAI’s official documentation.
/documents- Create and edit Word documents.
/pdf- Read, create, and inspect PDFs.
/presentations- Create and edit presentations.
/spreadsheets- Work with spreadsheets, formulas, and tables.
/visualize- Build an interactive visualization.
/ui_test- Test a user interface in a real browser.
/full_stack_e2e_review- Review a product end to end, from its interface to its data and backend.
/eu_ai_act_project_scan- Screen a project for issues relevant to the EU AI Act.
Glossary
- adapter
- A connecting piece of code that makes two parts fit together. Like a travel adapter for a wall socket.
- agent
- An AI program that can carry out several steps of a task by itself. For example read files, run code and fix errors.
- agent program
- A program that lets an AI model work by itself. It gives the model access to files and tools.
- API
- A door that two programs use to talk to each other.
- backend
- The part of a system you do not see. Here it is the agent program behind the chat.
- Claude Code
- Anthropic's AI assistant for programming. It can read and change the code in a project.
- CLI
- A program you control by typing commands instead of clicking.
- Codex
- OpenAI's AI assistant for programming. It can read and change the code in a project.
- first-in, first-out queue
- A queue where whoever came first is served first. Like the queue in a supermarket.
- forum topic
- A topic in a Telegram group. Each topic has its own thread of messages.
- LaunchAgent
- A setting on a Mac. It starts a program automatically and keeps it running.
- local
- On my own computer. A program running locally can still use the network or send data to another service.
- metadata
- Information about a thing, not the thing itself. For example when a message was sent.
- model- and harness-agnostic
- The bridge does not care which model and which agent program I choose. I can swap them.
- Node.js
- A program written in the JavaScript language. Node.js is the tool that runs it.
- OpenClaw
- A freely available program that lets you write with an AI assistant through a chat app.
- OpenCode
- A freely available agent program. It can use AI models from many providers.
- OpenCode Go
- A service that runs AI models for me on its own computers.
- reasoning effort
- A setting for how much the model should think before it answers. High effort is often slower and more thorough, but it promises neither a certain response time nor a correct answer.
- session
- One conversation or stretch of work with an AI assistant, from start to finish. A new session does not remember the old one by itself, but the program can hand it saved notes and messages.
- skills
- Ready-made recipes that an AI assistant can follow for a certain kind of task.
- Supertonic
- An AI model that reads text aloud with a voice. It runs on my own computer.
- token
- A small piece of text, often a word or part of a word. The model reads and writes one token at a time.
- Whisper
- An AI model that turns speech into text.