# Channels

A message to the bot on Telegram, Discord, Slack or personal WeChat starts a turn for the bound agent; the reply returns to the same chat. Channels run inside the background worker. No public webhook: every adapter connects outward (Telegram long-poll, Discord Gateway, Slack Socket Mode, WeChat iLink long-poll).

| Step | Does |
| --- | --- |
| Parse | An adapter in `openprogram/interfaces/channels/implementations/` parses the native event into one `ChannelMessage`: text, attachment metadata, quoted text. |
| Gate | `base.Channel.handle_inbound` runs the pairing gate (unknown senders get a one-hour code only the owner can approve, from the CLI or loopback Web UI), attachment download and the quoted block. |
| Dispatch | `dispatch_inbound` picks the agent from bindings, computes the session key, runs the turn under a per-session lock, and broadcasts it to the Web UI and TUI. |
| Send | One transport module owns chunking, per-platform formatting (Telegram HTML, Slack mrkdwn, plain text for WeChat), rate-limit retry and file upload. Where edits are allowed, progress streams into one placeholder. |

Scripts, jobs and agent methods can send one-shot with `outbound.send(...)` without a worker. Accounts, pairing and routing: `openprogram channels setup`, `accounts`, `access`, `bindings`.

| Document | Covers |
| --- | --- |
| [Design](https://fzkuji.github.io/OpenProgram/docs/reference/design/channels/design.html) | Structure and message flow: two send paths, `dispatch_inbound`, transport, platforms, user entry points |
| [Requirements and invariants](https://fzkuji.github.io/OpenProgram/docs/reference/design/channels/audit.html) | What the layer holds to, compared with OpenClaw and Hermes |
| [Chat-bot behaviour](https://fzkuji.github.io/OpenProgram/docs/reference/design/channels/chat-bots.html) | When an agent answers in a room, how it shows progress, what groups ask of it |
