How Switchboard works

Switchboard is a small, dependency-free relay between Telegram and your AI agent. Here's what it does with each message, where it runs, and how it keeps people and bots in line.

Updated

⚡ The short version

People ⇄ Telegram ⇄ Switchboard ⇄ your AI agent (Claude Code Web, GrokBot, Muse…)

You make a Telegram bot. Switchboard reads that bot’s messages, decides who is allowed to talk to it, and hands each message to your agent, with one agent session per chat. The agent answers through Switchboard, which takes care of Telegram’s formatting, typing indicators, buttons and files.

It is open source (MIT), written in Python and dependency-free.

🖥️ Where it runs

There is no Switchboard server. It runs on infrastructure your agent already has:

Agent Where Switchboard runs
Claude Code Web Inside a long-running “router” Claude Code session, as an MCP server. Each chat gets its own worker session.
GrokBot A small poller on the Grok Bot’s own computer, which posts each message to a webhook routine. Each group gets its own Grok Bot.
Muse A small poller on Muse’s own computer. Muse hooks wake a background worker for each message.

Your messages go between Telegram and your agent, and through no one else’s server.

📨 What happens to a message

  1. Telegram delivers it to the poller

    Exactly one program reads each bot’s messages. Telegram allows only one, and Switchboard enforces this with a lock.
  2. Access check

    Switchboard checks who sent it and where: the owner, a group member, or another bot. Messages that aren’t allowed stop here.
  3. Is it for the bot?

    In a group, the bot reacts to @mentions and replies to its own messages. In smart mode (/mode smart), every message from a person goes to the agent, which decides whether it was meant for it.
  4. Routing

    The message goes to the agent for that chat. Every DM and group has its own, so conversations never mix. On Claude Code Web, each forum topic gets its own session too. On GrokBot and Muse, a group’s topics share one agent, and replies go to the right topic.
  5. Context

    In groups, the bot quietly keeps the last 15 messages that weren’t addressed to it, and passes them along with the next one that is. So it knows what the group was talking about.
  6. The reply

    The agent answers with Markdown, and optionally buttons, files or an approval request. Switchboard sends it, quoting the message it answers in a group.

🔐 Who can talk to the bot

The owner

The first person to DM the bot /start becomes its owner. Only the owner can DM it.

Groups the owner added it to

Anyone in those groups can @mention it or reply to it, up to 20 messages an hour per member by default. Co-owners, listed in the bot’s access.json (reference), get owner powers in groups.

Other bots,

in those same groups, within the loop guards below.

Owner commands such as /new, /stop, /mode and /settings only work for the owner (and co-owners, in groups). Before a risky action, the agent can post Approve / Deny buttons that only the owner, a co-owner or an approver listed in access.json can tap.

🤖 Agents talking to agents

Put several bots in one group, with Bot-to-Bot Communication Mode turned on for each in @BotFather, and they can hand work to each other. A Claude coding agent can ask a GrokBot image agent for a picture, for example. To stop two bots from chatting forever, Switchboard applies Telegram’s loop-prevention rules to every bot message addressed to your bot:

Guard Default
Most bot messages in a row, before a person writes again 5
Shortest gap between replies to the same bot 5 seconds
Longest bot-to-bot exchange 15 minutes
The same bot message repeated dropped for 10 minutes

Bot messages that aren’t addressed to your bot never get a reply. More in how to put several AI agents in one Telegram group.

🔑 The bot token

The token is the key to your bot. Switchboard never logs it, and the setup never asks you to paste it into a chat:

Claude Code Web

It’s a variable in the cloud environment, which you set yourself in Claude Code settings. Worker sessions never see it.

GrokBot

It’s a GrokBot secret.

Muse

It’s saved in a Muse connection. Switchboard only sees a stand-in, which Muse’s gateway swaps for the real token on requests to Telegram.

⌨️ Commands

Command What it does
/help What the bot can do
/new Start a fresh session for this chat or topic
/stop Stop the current task
/status Which session answers this chat
/settings The owner, who can use the bot, limits and groups
/mode smart, /mode mention Answer when the agent thinks it’s meant (smart), or only to @mentions and replies (mention, the default)
/groupphoto, /groupdesc, /refreshgroup The agent draws a group photo, writes a description from the recent chat, or both (owner only; the bot must be an admin with Change group info)

The full list, with every setting, is in the reference.

🧩 Add your own agent

Every agent plugs into the same relay, so a new one only needs a small adapter: how messages reach it, one session per chat, and how it replies. The access rules, loop guards and the single poller come for free. See adding a platform.