remote — Messenger Bridge Setup Ladder
Use this skill when the user wants codexclaw reachable from Telegram or Discord ("텔레그램 연결해줘", "connect discord", "set up remote"). The agent runs every step below itself and verifies each one; the user is only needed for the two steps a bot platform requires a human for (creating the bot and tapping the pairing trigger).
All API calls target the local bridge at http://127.0.0.1:7717. Every
mutating request MUST send BOTH headers, or the server answers 403:
bash-H 'content-type: application/json' -H 'x-codexclaw-local: 1'
Ladder (both platforms)
- Preflight — is the bridge up?
curl -s http://127.0.0.1:7717/api/health->{"ok":true,...}. Not running? Foreground:cxc serve --port 7717 --cwd <project>. Daemon (macOS launchd):cd <project>FIRST (install binds the current working directory as--cwd), thencxc service install --port 7717. Check withcxc service status; logs at~/.codexclaw/serve.{out,err}.log. There is noserve statussubcommand. On Linux, use systemd user units. On Windows, use Task Scheduler. See platform-specific sections inreferences/telegram.mdandreferences/discord.md. - Token (human step). Walk the user through bot creation — exact steps in references/telegram.md / references/discord.md. Never echo the token into logs, commit it, or paste it back in chat responses.
- Create the named agent (validates the token).
GET /api/agentsto see existing ones. New:POST /api/agentswith{"name":"...","kind":"telegram"|"discord","token":"..."}— the server validates via TGgetMe/ DCusers/@meand answers 400 on a bad token (stop and re-ask), 200 withusername/botIdon success. Existing agent:POST /api/agents/updatewith{"id":<n>,"token":"..."}(same validation). ThenPOST /api/agents/enablewith{"id":<n>,"enabled":true}. - Pair the chat (human tap). Snapshot the baseline first:
GET /api/agents/handshake/status?id=<n>-> noteallowlistCount.- TG preferred — one-tap deep link:
POST /api/agents/pairing-linkwith{"id":<n>,"seconds":600}(default 600, cap 3600) returns{"ok":true,"url":"https://t.me/<bot>?start=<code>","code":..., "expiresAt":...}. Send theurlto the user; tapping it makes Telegram send/start <code>— the code is single-use and TTL-bounded, no open window needed. Never paste the code anywhere else. - Window fallback (and the only DC path):
POST /api/agents/handshake/openwith{"id":<n>,"seconds":120}(default 120, cap 600); the user sends/start(TG) or types!cxc startin a channel the bot can read (DC — pairing is a text trigger; slash commands reject unpaired channels). Either way, poll the status endpoint: pairing succeeded whenallowlistCountgrows past the baseline; on expiry mint a fresh link or reopen the window.
- TG preferred — one-tap deep link:
- Smoke test.
POST /api/agents/test-sendwith{"id":<n>}messages the newest paired chat (an explicit"chatId"must already be paired; 400 otherwise). Then have the user send/status(TG) or!cxc status(DC) — the first gateway command creates the binding row, and only THEN doesGET /api/bindingsshow it. - Anything wrong -> references/troubleshooting.md (symptom -> cause -> fix, all distilled from real incidents).
Platform references
Human-facing overview: the bridge README (served at
http://127.0.0.1:7717/readme while the bridge runs).
- references/telegram.md — BotFather steps, TG
command surface, forum-topic sessions, optional webhook mode
(HTTPS
/webhook/telegram/<secret>, auto-fallback to long-poll). - references/discord.md — Developer Portal steps,
Message Content intent, invite URL (
scope=bot&permissions=3072), slash vs text command split, thread mode (slash:/mode value:thread|plain; text:!cxc mode thread|plain).
Scope guard
- The GUI at
http://127.0.0.1:7717can do this visually: the Agents page is the named-agent setup flow (same/api/agents/*surface); the Channels page is the legacy single-channel shim. Offer the Agents page when the user prefers clicking over chat. /api/connect/*is the legacy single-channel shim (itsvalidateeven stores the token as a side effect); teach and use the/api/agents/*surface.- This skill configures the bridge only. Bridge behavior changes (commands,
adapters, gates) are
cxc-devterritory, not setup.


