AAnvio
Channels

Channel Adapters

The ChannelAdapter interface and the 15 channel implementations that ship in @anvio/channels.

5 min read

@anvio/channels ships 15 channelType implementations. Three are always registered (cli, web-chat, rest); the other twelve register only when their required credentials are present.

The ChannelAdapter interface

interface ChannelAdapter {
  readonly channelType: ChannelType;
  sendMessage(sessionId, message): Promise<void>;
  sendProgress?(sessionId, update): Promise<void>;
  sendNotification?(sessionId, notification): Promise<void>;
  sendApprovalRequest?(sessionId, request): Promise<void>;
  onMessage(handler): void;
  start(): Promise<void>;
  stop(): Promise<void>;
}

Most adapters extend BaseChannelAdapter (packages/channels/src/base-channel-adapter.ts), which implements sendProgress/sendNotification/sendApprovalRequest in terms of sendMessage — so a new adapter only has to implement sendMessage, start, stop, and sendApprovalRequestWithActions.

Adapter table

ChannelchannelTypeFileTransport
CLIclicli-channel.tsLocal stdin/stdout, always on
Web Chatweb-chatweb-chat.tsGateway WebSocket (:3001/ws), always on
REST APIrestrest-api.tsHTTP (/api), always on
Telegramtelegramtelegram.tsLong-polling (Telegram Bot API)
Discorddiscorddiscord.tsGateway WebSocket (native, no discord.js)
Slackslackslack.tsSocket Mode (no public webhook needed)
WhatsAppwhatsappwhatsapp.tsMeta Cloud API webhook
Microsoft Teamsteamsteams.tsBot Framework webhook, fetchWithRetry backoff
Matrixmatrixmatrix.tsHomeserver webhook, fetchWithRetry backoff
Emailemailemail.ts + imap-client.ts + smtp-client.tsIMAP (real RFC 2177 IDLE, poll fallback) / SMTP
Signalsignalsignal.tssignal-cli REST
Google Chatgoogle-chatgoogle-chat.ts + google-chat-auth.tsWebhook or service-account JWT + REST
Feishu / Larkfeishufeishu-channel.tsWebhook
SMSsmssms-channel.tsTwilio REST
Mattermostmattermostmattermost.tsREST API

Supporting files: channel-hub.ts (registry), create-channels.ts (composition), channel-hub-bundle.ts (return type of createChannelHub), channel-session-bridge.ts (thread ↔ session mapping), channel-health.ts (status probes), agent-inbox.ts + filesystem-inbox.ts (mid-run instruction injection), webhook-channel-base.ts (shared webhook adapter base), fetch-retry.ts (shared backoff helper for Teams/Matrix).

Setup by channel

# workspace/anvio.yaml
spec:
  channels:
    telegram:
      enabled: true
      defaultAgent: architect

Set TELEGRAM_BOT_TOKEN (or botToken in config). Long-polling — no webhook or public URL required. Supports forum topics via message_thread_id, and inline Approve/Reject buttons for tool approvals.

spec:
  channels:
    discord:
      enabled: true
      defaultAgent: architect

Set DISCORD_BOT_TOKEN. Enable Message Content Intent in the Discord Developer Portal. Uses a native WebSocket Gateway connection — no discord.js dependency. Thread channels map 1:1 to agent sessions; button components render Approve/Reject.

spec:
  channels:
    slack:
      enabled: true
      defaultAgent: architect

Requires both SLACK_BOT_TOKEN (xoxb-...) and SLACK_APP_TOKEN (xapp-..., needs connections:write scope). Uses Socket Mode — no public webhook URL, local-first friendly. Enable Socket Mode in Slack app settings and subscribe to message.channels, message.im, message.groups. Slack thread_ts maps to an agent session; approvals render as Block Kit buttons.

spec:
  channels:
    whatsapp:
      enabled: true
      defaultAgent: architect

Requires WHATSAPP_ACCESS_TOKEN (Meta Cloud API token), WHATSAPP_PHONE_NUMBER_ID, and WHATSAPP_VERIFY_TOKEN (default anvio-verify). Inbound arrives via a Meta webhook at:

https://<your-host>/api/channels/whatsapp/webhook

Outbound uses Graph API v21.0. Sessions map by phone:{wa_id}. Requires the API app running alongside the worker:

pnpm --filter @anvio/api dev
pnpm --filter @anvio/worker dev
spec:
  channels:
    email:
      enabled: true
      defaultAgent: architect

Env vars: EMAIL_SMTP_HOST, EMAIL_IMAP_HOST, EMAIL_IMAP_PORT (default 993), EMAIL_USERNAME, EMAIL_PASSWORD, EMAIL_POLL_INTERVAL_MS (default 60000), EMAIL_FROM. Set EMAIL_IMAP_IDLE=1 to use real RFC 2177 IDLE — a persistent connection that wakes immediately on untagged EXISTS/RECENT/EXPUNGE, falling back to the fixed-interval poll loop when the server's CAPABILITY doesn't advertise IDLE. Message-ID/References headers thread replies correctly.

spec:
  channels:
    signal:
      enabled: true
      defaultAgent: architect

Requires SIGNAL_CLI_PATH (path to a running signal-cli REST daemon) and SIGNAL_PHONE_NUMBER. Outbound delivery is live over the signal-cli REST API.

Other adapters (config only)

ChannelEnv vars
TeamsTEAMS_APP_ID, TEAMS_APP_PASSWORD, TEAMS_SERVICE_URL
MatrixMATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_USER_ID, MATRIX_ROOM_ID
Google ChatGOOGLE_CHAT_WEBHOOK_URL, or GOOGLE_CHAT_SERVICE_ACCOUNT + GOOGLE_CHAT_SPACE for service-account JWT auth
FeishuFEISHU_WEBHOOK_URL
SMS (Twilio)TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_FROM_NUMBER
MattermostMATTERMOST_SERVER_URL, MATTERMOST_BOT_TOKEN

Agent inbox (mid-run instructions)

Inject an instruction into a running session from any channel:

anvio inbox <sessionId> "Focus on security issues first"
anvio inbox <sessionId> stop

Messages queue in LocalAgentInbox and dispatch via the AGENT_INBOX_INJECTED event; they persist to workspace/inbox/<sessionId>.json and survive a process restart (packages/channels/src/filesystem-inbox.ts).

Human approval

When a tool call requires approval, the runtime pauses in awaiting_approval status. The worker publishes APPROVAL_REQUESTED, and each adapter renders its own native affordance — inline buttons on Telegram/Discord/Slack, or plain text elsewhere:

anvio approve <sessionId> <requestId>
anvio approve <sessionId> <requestId> --reject

Voice

ChannelConfig.voice (and per-channel telegram.voice / discord.voice) enables a shared VoicePipeline (@anvio/voice) for STT/TTS on channels that support audio attachments, gated by ANVIO_CHANNEL_VOICE=1 or explicit voice.enabled: true.

Not yet shipped

Full Discord voice-channel join (joining a live voice call) is not implemented — only audio attachment transcription/synthesis. A native Discord voice gateway client would be required for full VC support (docs/69-post-v1.17-gap-register.md, item V4).

Edit on GitHub

Last updated on

On this page