See Your AI

Telegram

Everything about running a bot on Telegram with the harness — the setup, and the handful of non-obvious platform gotchas that will otherwise cost you an afternoon. Most of these aren’t seeyourai quirks; they’re Telegram Bot API + BotFather behavior that nothing warns you about.

Setup — a fresh bot on Telegram

  1. Token: DM @BotFather → /newbot → copy the token.
    seeyourai bot config <bot> set TELEGRAM_BOT_TOKEN=123456:ABC...
    
  2. Enable the channel in the bot’s launch command (BOT_CMD in its .env): --channels plugin:telegram@claude-plugins-official. If the bot also loads bot-mesh or another development channel, put Telegram in that flag instead (see BOT-MESH.md).

    ⚠️ Install the plugin first — it is NOT bundled. On a fresh machine no plugins are installed, and --channels plugin:telegram@… then silently no-ops: the bot launches, --remote-control works, but nothing polls Telegram, so DMs are never received (and seeyourai bot access <bot> list shows no pending code no matter how many times you message it). Install once per machine, then confirm:

    claude plugin install telegram@claude-plugins-official
    claude plugin list   # -> telegram@claude-plugins-official ... enabled
    
  3. Set the operator — who gets the “back online” ping and the harness’s alerts (see below). Once per machine, and before the bot starts, or its own poller may take the code:
    seeyourai admin enroll          # prints a code to DM to the bot
    
  4. Start it: seeyourai bot run <bot>.
  5. Pair yourself — you never need to know your numeric id: DM the bot anything → it replies with a 6-char code → approve it:
    seeyourai bot access <bot> pair a1b2c3
    
  6. Lock it down once the right people are in:
    seeyourai bot access <bot> policy allowlist
    

Access is per-bot (multi-bot isolation)

Each bot runs its Telegram channel isolated — its own token and its own TELEGRAM_STATE_DIR (~/.seeyourai/channels/<bot>/telegram), so pairing state, allowlist, and inbox never collide between bots.

⚠️ The stock /telegram:access skill hardcodes the global ~/.claude/channels/telegram path and ignores TELEGRAM_STATE_DIR, so it can’t approve a pairing for an isolated bot. Always use seeyourai bot access <bot> — it targets the right per-bot access.json.

seeyourai bot access <bot> list               # policy, allowlist, pending, groups
seeyourai bot access <bot> pair <code>        # approve a DM pairing
seeyourai bot access <bot> policy allowlist   # pairing | allowlist | disabled

The operator channel: the “back online” ping and alerts

The harness has its own line to the person running the bots. It calls the Telegram HTTP API itself, with no agent or plugin involved, so it works when the bot is the broken part. It carries the “back online” message a SessionStart hook sends on every launch (the hook lives in a gitignored .claude/settings.local.json), and the alerts: crash loops, failing pushes, a bot stuck on a prompt, undelivered mail.

It goes to one Telegram user id, TELEGRAM_ADMIN_CHAT_ID in ~/.seeyourai/config, which every bot inherits. seeyourai admin enroll sets it by having you DM a code to the bot and sends a test message; seeyourai admin show says who gets alerts. A group id is refused, so an alert never lands in a group. With no id set, nothing is sent and the log says so. A bot with no token of its own borrows the token of another bot on the same machine, and the message still names the bot it is about; OPERATOR_TRANSPORT_BOT in the same file picks which.

TELEGRAM_CHAT_ID is something else: the bot’s own conversation chat.


⚠️ Inbound needs $TELEGRAM_STATE_DIR/.env — outbound doesn’t

The single most confusing Telegram failure: the bot sends its “back online” ping and any replies fine, but never receives your messages. It looks online; it’s deaf.

The reason is that the two directions use different credentials paths:

The harness provisions this file for you. On every launch, for any bot whose BOT_CMD uses the telegram channel and has a TELEGRAM_BOT_TOKEN, the watchdog writes $TELEGRAM_STATE_DIR/.env (mode 0600) containing the token (and TELEGRAM_CHAT_ID). You don’t need to create it by hand.

Diagnosing a bot that pings but doesn’t hear you:

# Is the poller alive? A live PID here means it's consuming getUpdates.
cat "$TELEGRAM_STATE_DIR/bot.pid"          # e.g. ~/.seeyourai/channels/<bot>/telegram/bot.pid
# Is the token file present?
ls -l "$TELEGRAM_STATE_DIR/.env"
# Is there a telegram plugin subprocess under the agent?
pgrep -af "plugins/cache/claude-plugins-official/telegram"

No bot.pid / no plugin subprocess ⇒ the poller exited, almost always because $TELEGRAM_STATE_DIR/.env was missing.


Interactive-picker tools never reach Telegram

Some Claude Code tools render a choice widget in the Claude Code app’s own UI — e.g. the tool that asks “which of these should I do?” with clickable options. That UI is local to the app; it never gets forwarded through a channel plugin. A user driving the bot purely through Telegram just sees the session go quiet, with no way to answer — from their side it looks hung, not like it’s waiting on them.

For example: mid-task, Claude asks the user to pick between a few options via the picker tool while the user is only ever talking to the bot over Telegram. The session stalls from the user’s point of view until they ask, over Telegram, what is going on.

Fix: when the current turn came in from a Telegram message, ask decisions as a plain text question in a normal reply — list the options inline (e.g. “A) first option B) second option C) third option — which one?”) — and treat the next inbound Telegram message as the answer, instead of calling an interactive-picker tool. This generalizes to any Claude-Code-app-only affordance: if it’s a UI element rather than a chat message, a Telegram-only user can’t see or answer it.


Groups — read this before you lose an afternoon

1. Use a GROUP, not a CHANNEL

A channel is broadcast / one-way: a bot there must be an admin and there’s no real back-and-forth. For a bot you actually chat with, make a group. (Tell them apart: a channel’s composer says “Broadcast” and it has “subscribers.”)

t.me/+… invite links are for human accounts; a bot can’t join through one. A member/admin must add it: group title → Add Members → search the bot’s @username.

3. chat_id and the -100 prefix

The Bot API chat_id isn’t always what the web URL shows:

Chat type web.telegram.org URL Bot API chat_id
Basic group #-1234567890 -1234567890
Supergroup / channel #-1234567890 -100 + 1234567890 = -1001234567890

A wrong-prefix (or not-a-member) send returns 400 chat not found — that error means wrong id or not a member, not a permissions problem.

4. Allowlisting a group gates OUTBOUND too

A bot can’t even post to a chat that isn’t in its allowlist. Add the group to the bot’s access.json under groups:

"groups": { "-1234567890": { "requireMention": false, "allowFrom": [] } }

The poller re-reads access.json on every inbound — no restart needed. seeyourai bot access does not edit groups; edit the json directly.

5. ★ Privacy mode — the silent killer

BotFather enables privacy mode by default. A privacy-ON bot in a group receives only messages that @mention it, replies to its own messages, and /commands — never plain chatter. This is the #1 reason a correctly-added, correctly- allowlisted bot still says nothing.

Check it from the bot’s own token (no poller conflict):

curl -s "https://api.telegram.org/bot<TOKEN>/getMe" | grep -o '"can_read_all_group_messages":[a-z]*'
# false  → privacy ON  (mentions/replies/commands only)
# true   → privacy OFF (sees all group messages)

Fix: @BotFather → /setprivacy → pick the bot → Disable → then remove and re-add the bot to the group (the change only applies to groups it joins after the toggle).

6. Bots can’t hear other bots

Telegram never delivers a bot’s messages to another bot — in DMs or groups. So two bots can’t drive each other (e.g. “take turns counting” won’t work on its own): the second bot never sees the first’s message. A back-and-forth needs a human, or one orchestrator relaying between them.


Diagnosing with the bot’s own token (read-only)

You can introspect a lot without touching the running poller:

TOKEN=$(seeyourai bot config <bot> get TELEGRAM_BOT_TOKEN)
curl -s "https://api.telegram.org/bot$TOKEN/getMe"
curl -s "https://api.telegram.org/bot$TOKEN/getChatMember?chat_id=<group>&user_id=<botId>"

Avoid getUpdates while the bot is running — that’s what the live poller long-polls, and a second reader will fight it.

The access.json shape

Under each bot’s TELEGRAM_STATE_DIR:

{
  "dmPolicy": "pairing",                      // pairing | allowlist | disabled
  "allowFrom": ["1234567890"],                // approved DM user ids
  "groups": { "-100…": { "requireMention": false, "allowFrom": [] } },
  "pending": {}                               // codes awaiting `access pair`
}