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
| Channel | channelType | File | Transport |
|---|---|---|---|
| CLI | cli | cli-channel.ts | Local stdin/stdout, always on |
| Web Chat | web-chat | web-chat.ts | Gateway WebSocket (:3001/ws), always on |
| REST API | rest | rest-api.ts | HTTP (/api), always on |
| Telegram | telegram | telegram.ts | Long-polling (Telegram Bot API) |
| Discord | discord | discord.ts | Gateway WebSocket (native, no discord.js) |
| Slack | slack | slack.ts | Socket Mode (no public webhook needed) |
whatsapp | whatsapp.ts | Meta Cloud API webhook | |
| Microsoft Teams | teams | teams.ts | Bot Framework webhook, fetchWithRetry backoff |
| Matrix | matrix | matrix.ts | Homeserver webhook, fetchWithRetry backoff |
email | email.ts + imap-client.ts + smtp-client.ts | IMAP (real RFC 2177 IDLE, poll fallback) / SMTP | |
| Signal | signal | signal.ts | signal-cli REST |
| Google Chat | google-chat | google-chat.ts + google-chat-auth.ts | Webhook or service-account JWT + REST |
| Feishu / Lark | feishu | feishu-channel.ts | Webhook |
| SMS | sms | sms-channel.ts | Twilio REST |
| Mattermost | mattermost | mattermost.ts | REST 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: architectSet 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: architectSet 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: architectRequires 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: architectRequires 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/webhookOutbound 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 devspec:
channels:
email:
enabled: true
defaultAgent: architectEnv 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: architectRequires 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)
| Channel | Env vars |
|---|---|
| Teams | TEAMS_APP_ID, TEAMS_APP_PASSWORD, TEAMS_SERVICE_URL |
| Matrix | MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_USER_ID, MATRIX_ROOM_ID |
| Google Chat | GOOGLE_CHAT_WEBHOOK_URL, or GOOGLE_CHAT_SERVICE_ACCOUNT + GOOGLE_CHAT_SPACE for service-account JWT auth |
| Feishu | FEISHU_WEBHOOK_URL |
| SMS (Twilio) | TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_FROM_NUMBER |
| Mattermost | MATTERMOST_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> stopMessages 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> --rejectVoice
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).
Last updated on