# Channels (https://docs.neuralisapp.com/agent-core/channels)

<Callout title="Maturity: preview (55 %)">
**Messaging channels.** Telegram and WhatsApp connect a person's messaging account to project workflows: unknown senders pair first, messages fire workflows under the normal permission and quota rules, and answers return to the same chat.

- Telegram and WhatsApp are the only messaging platforms.
- Delivery sends finished answers, not a live stream.
- Channels run in a single process; a second replica would answer every message twice.

[How maturity is measured](https://docs.neuralisapp.com/getting-started/maturity.md)
</Callout>

A **channel** connects an external messaging account — a Telegram bot or a
WhatsApp Business number — to your project's workflows. Once connected and
paired, a message from your phone fires a workflow, the run executes inside
Neuralis under the usual permission and quota rules, and the result comes back
to the same chat.

- **Connections are personal.** Each user connects their *own* account
  (`channels.connect`, a member default). The bot token is stored encrypted in
  *your* credential scope, and other members cannot see your connection.
  Project-wide connections exist too, managed by owners and admins
  (`channels.manage`).
- **Unknown senders never reach an agent.** A stranger messaging your bot gets
  an expiring 8-character pairing code and nothing else; only after you approve
  it does that sender's message fire anything.
- **Delivery is finished answers, not a live stream.** Thinking and tool events
  never leave the platform.

## Tutorial: connect Telegram [#tutorial-connect-telegram]

Telegram uses **long-polling by default — your instance needs no public URL**,
so the whole flow works on a laptop behind NAT.

1. **Create a bot.** Message [@BotFather](https://t.me/botfather), send
   `/newbot`, pick a name and a username ending in `bot`, and copy the **HTTP
   API token** it returns. Paste it only into the Neuralis wizard — never into a
   chat with an agent.
2. **Connect it.** Open the **Calendar** widget, click **Channels**, pick
   **Telegram** under *My channels*, paste the token, keep **Polling** and click
   **Validate & connect**. The token is checked live against the Bot API and
   stored in your own credential scope; the card shows the bot's `@username`.
3. **Pair yourself.** Message the bot from your own Telegram account. It replies
   with a pairing code (valid 1 hour, at most 3 pending per connection). Expand
   the connection card and **approve** the request — the sender is linked to
   *you*. Linking a peer to a different user needs `channels.manage`.
4. **Bind a workflow.** In the workflow editor's **Channel bindings** section,
   click **Bind**, pick your connection and keep *Reply with the run result*.
   Make sure the workflow is **active**. The fastest path is the shipped
   **Channel assistant** [template](https://docs.neuralisapp.com/agent-core/workflows.md#default-templates),
   which is already set up as a chat bot.
5. **Test it.** Message the bot again. The bound workflow fires within a couple
   of seconds, and the answer arrives in 4 000-character chunks with code fences
   intact.

For a chat-style bot, two settings matter: **Schedule: Manual only** (the
message trigger fires on every inbound message; add a cron only if it should
also run on a timer) and **Mode: One thread**, so every message continues the
same conversation. *Fresh per fire* suits stateless tasks.

A binding is the *only* path from a channel into an agent — there is no "route
to any agent" fallback. It attaches a system-managed `message` trigger that only
deleting the binding removes. One connection may be bound to several workflows,
and then **one message fires all of them** (the editor warns you). You can also
ask your agent: the `workflow` tool creates the workflow and a
`manage-workflows` script binds it, and `manage-channels` can check, disconnect,
reconnect, unlink and — after your explicit ask and a confirmed binding count —
delete a connection. Creating one stays with you, because it takes a secret.

Your message rides into the run as **untrusted, delimited context** after the
instruction, never parsed into placeholders, and the run executes as the
workflow's creator. The context's source line names the Neuralis user the
sender is linked to, taken from the pairing record and never from the message.

## Tutorial: connect WhatsApp [#tutorial-connect-whatsapp]

WhatsApp uses the **Business Cloud API** and is **webhook-only**: your instance
must be reachable on a public HTTPS URL, and that proxy must be declared in
`NEURALIS_TRUSTED_PROXIES` ([deployment](https://docs.neuralisapp.com/enterprise/deployment.md)) or the webhook
rate cap applies to all senders together.

1. **Collect four values** from a Business app with the WhatsApp product in
   [Meta for Developers](https://developers.facebook.com/): a permanent
   **access token** (from a system user — the dashboard's temporary one expires
   in 24 h), the **phone number ID**, the **app secret** (it signs every webhook
   delivery; unsigned ones are rejected), and a **verify token** you invent.
   Where your Meta app supports it, **Sign in with WhatsApp** fills the access
   token, once an administrator has stored `oauth.whatsapp.clientId` /
   `oauth.whatsapp.clientSecret` and registered the redirect
   `https://<your-host>/api/oauth/whatsapp?action=callback` exactly.
2. **Connect it** under **Calendar → Channels → WhatsApp**. The token and phone
   number id are checked live against the Graph API. Note the connection id
   (`ch-…`).
3. **Subscribe the webhook** in the Meta app: callback URL
   `https://your-neuralis-host/api/webhooks/channels/<connectionId>`, the same
   verify token, then the **messages** field. Every delivery is verified with
   `X-Hub-Signature-256` over the raw body before anything is parsed.
4. **Pair and bind** as for Telegram. WhatsApp's 24-hour customer-service window
   applies.

A project-scope connection is created by an owner or admin first; its card
prints the exact derived credential ids (`telegram.botToken.ch-…`-style) to
create as project-scope credentials. Channel secrets always resolve per
connection under those ids, never under a shared one.

## Inbound policies [#inbound-policies]

| `dmPolicy` | Behavior |
| --- | --- |
| `pairing` (default) | Unknown senders get an expiring code; approval creates a peer link. |
| `allowlist` | Only listed platform ids may even hold a pairing request; everything else drops silently. |
| `disabled` | All unlinked inbound drops silently. |

There is deliberately no `open` mode. In group chats a binding must allow the
group id, the sender must still be a linked peer, and codes are never sent into
groups. Duplicate deliveries are de-duplicated, messages from one peer within
2 s coalesce into one fire, and each connection is capped at
`channelInboundFiresPerMinute` fires (30 by default; over-cap messages drop
silently and are audited). Spend limits still govern every fire.

## Delivery [#delivery]

- A **message-fired run** replies to the originating chat. Answers go out **as
  the agent finishes them**, so a hand-off to a background subagent sends "I
  have started" at once and the result as its own message later.
- **Reply style** is *Off*, *Final answers only* (the default) or *Everything
  it writes*, which adds the agent's notes between tool calls. Binding settings
  are fixed at bind time — delete and re-add the binding to change them.
- Typing into the same conversation from the web chat mirrors the reply to
  *your* direct chat only, and only while the conversation is bridged to one
  chat; a teammate's turn and group chats never receive it.
- A failed run sends a fixed, neutral notice — the real error stays on the run
  row and the audit log. A run stopped before it started gets a fixed notice
  too; one cancelled mid-work stays silent.
- A **scheduled or manual run** delivers only if its delivery policy announces
  to selected bindings (*Announce scheduled runs*). Bridging a conversation
  never gives a scheduled run a voice on the channel.
- A final text of exactly `NO_REPLY` delivers nothing ("If nothing significant
  happened, answer NO_REPLY") — the whole reply must be the token.

A workflow can also be fired over plain HTTP — see
[the fire endpoint](https://docs.neuralisapp.com/agent-core/workflows.md#the-fire-endpoint).

## Guarantees [#guarantees]

- Connection records hold **credential references only**; secrets live in the
  encrypted store at the owning scope and are never echoed.
- Members write channel secrets only into their *own* user scope, and only for
  channel credential ids.
- Webhook ingress verifies signatures over the raw body first; an unknown
  connection id is indistinguishable from a bad signature.
- Deleting a connection, unlinking a peer and removing a binding are audited,
  whoever did it.
- The channel data folder is unreadable through the filesystem tools; connection
  metadata is reachable only through the channel routes, scoped to the caller.

| Telegram transport | Public URL | Notes |
| --- | --- | --- |
| Polling (default) | Not needed | One long-poll worker per connection. Do not run two replicas on one bot token (Telegram answers 409). |
| Webhook | Required | A per-connection secret header token, generated automatically. |