Docs/Architecture/Channels & Integrations

Channels & Integrations

Ten channel types feed one agent runtime. Inbound traffic arrives on provider-specific webhook endpoints in core/omnichannel, gets normalised into channel sessions, routed to an agent, and answered through the matching outbound adapter. Contact pairing, operator handoff and per-channel plan gates sit on top. Webhook paths verified against the controllers; channel set from the ChannelType enum.

flowchart LR
  subgraph ext["External platforms"]
    WA["WhatsApp
(Twilio / Meta Cloud)"] & TG["Telegram"] & SL["Slack"] & DC["Discord"] & MS["Teams"] & META["Messenger /
Instagram / X"] & EM["Email (IMAP)"] & VO["Voice
(LiveKit / Twilio PSTN)"] end ext --> WH["/webhook/* controllers
signature verification"] WH --> NORM["Normalise → channel session
contacts / pairing / routing"] NORM --> SEL["AgentRelevanceSelector
(Jev: which agent replies)"] SEL --> AGENT["AgentChatService
+ GuardedToolCallback pipeline"] AGENT --> OUT["Outbound adapters
(per-channel credential rows)"] AGENT -->|"request_human tool"| OP["Operator handoff inbox"]

1. Channel types

ChannelType: WHATSAPP, MESSENGER, INSTAGRAM, SLACK, DISCORD, X, TELEGRAM, EMAIL, TEAMS, VOICE. WhatsApp has three distinct transports (Twilio, Meta Cloud API, and the unofficial QR path) under one type.

2. Inbound webhook surface

PathChannel / providerNotes
POST /webhook/twilio/whatsappWhatsApp via TwilioForm-encoded; Twilio signature validation
POST /webhook/twilio/smsSMS via TwilioTwilioSmsWebhookController
POST /webhook/twilio/voice[/collect|/menu-collect]PSTN voice via TwilioTwilioVoiceWebhookController — gather/collect turns
POST /webhook/twilio (status)Twilio delivery statusTwilioStatusCallbackController
GET/POST /webhook/meta/whatsappWhatsApp via Meta Cloud APIGET = verification challenge, POST = messages
GET/POST /webhook/meta/socialMessenger / InstagramMetaSocialWebhookController
POST /webhook/telegram/{botUserId}TelegramPer-bot webhook keyed on bot user id
POST /webhook/discordDiscordInbound via a Node gateway service, which calls this endpoint
POST /webhook/slackSlackEvents API surface
POST /webhook/teams/{appId}Microsoft TeamsPer-app-id routing
— (polled)EmailEmailInboundPollingJob over IMAP — no webhook
— (WebRTC/WS)VoiceLiveKit browser call + Twilio voice relay WebSocket; see §4

3. Session, pairing and routing model

4. Voice pipeline

Two independent voice paths exist and are deliberately not unified:

PathTransportPipeline
In-app calling (core/voice)LiveKit WebRTC, browser-to-agent, zero PSTNLiveKit token issuance → push-to-talk STT → AgentChatService → TTS
PSTN voice (omnichannel/twilio)Twilio voice + relay WebSocketvoice-agent worker: Silero VAD → Whisper STT → core SSE turn → ElevenLabs TTS

All TTS output passes through SpeechTextNormalizer (core/speech) so the engine says something sensible — markdown, emoji and raw URLs are rewritten before synthesis. ElevenLabs voice cloning is BYOK per tenant (own credential table); Sarvam covers the Indic-language STT/TTS surface.

5. Credential storage

Each channel connection stores provider credentials as encrypted rows in the tenant schema (AES-256-GCM via EncryptionService) — e.g. TwilioCredential, MetaWhatsAppCredential, DiscordCredential, Google refresh tokens. Outbound adapters read them at send time; webhook inbound paths authenticate via provider signature validation rather than JWT.

6. Known risks and quirks

WhatsApp uses official paths only

WhatsApp connects through Meta's WhatsApp Cloud API or a Twilio WhatsApp sender. Unofficial personal-number clients violate WhatsApp's terms of service and are not part of this platform.

AreaBehaviour
DiscordNot a direct webhook from Discord — a Node gateway service maintains the socket and forwards into /webhook/discord
EmailPolling job, not push — inbound latency is bounded by the IMAP poll interval
Meta webhooksGET challenge + POST messages on the same path; signature verification required before processing
VoiceTwo stacks (LiveKit in-app, Twilio PSTN) — check which one a report refers to before debugging