Channels
Overview
Section titled “Overview”Channels act as the bridge between Evonic agents and external messaging platforms. They allow users to interact with agents through their preferred interface — Telegram, WhatsApp, Discord, Slack, or the web UI — without changing how the agent works underneath.
The architecture is fully modular: adding a new channel type requires implementing a standard interface, allowing Evonic to scale to any messaging protocol without modifying the core agent runtime.
How Channels Work
Section titled “How Channels Work”When a message arrives through a channel, the following flow occurs:
- Message Arrival: The channel implementation (e.g., a Telegram bot) receives a message from the external platform.
- Extraction: The channel extracts the
external_user_idand the message text. - Check Access: If the channel is in restricted mode, the system checks if the user is in the allowlist or has a pending pairing code.
- Runtime Dispatch: The channel calls
agent_runtime.handle_message(agent_id, user_id, text, channel_id). - Processing: The Agent Runtime:
- Identifies the correct session for that specific user on that specific channel
- Constructs the conversation context (System Prompt + History + New Message)
- Calls the LLM
- Executes any required tools through HMADS (Heuristic Mal-Activity Detection System)
- Response: The runtime returns a response string to the channel.
- Delivery: The channel sends the response back to the user on the original platform.
Channel Modes
Section titled “Channel Modes”Introduced in v0.2.0. Each channel has a mode that controls who can interact with the agent through that channel.
| Mode | Description |
|---|---|
| Open | Everyone is allowed to chat. No allowlist check. |
| Restricted | Only users in the allowlist can chat. New users receive a pairing code that an admin must approve. |
New channels default to restricted mode. You can change the mode at any time via the Channel Detail Modal in the Web UI (click on a channel card) or through the API.
Open Mode
Section titled “Open Mode”In open mode, any user who sends a message to the channel can immediately start interacting with the agent. No approval is needed.
{ "config": { "mode": "open" }}Restricted Mode
Section titled “Restricted Mode”In restricted mode, only users whose external_user_id is in the channel’s allowlist can chat. When an unregistered user sends a message:
- The channel checks if the user is already in the allowlist.
- If not, it checks for an existing non-expired pending approval for that user.
- If none exists, the system generates a pairing code and creates a pending approval record.
- The user receives the pairing code as a reply and must share it with an admin.
- An admin approves the code (via CLI or Web UI), adding the user to the allowlist.
- The user can now interact with the agent normally.
{ "config": { "mode": "restricted", "allowed_users": ["123456789", "987654321"] }}Pairing Codes
Section titled “Pairing Codes”Pairing codes allow users to request access to a restricted channel. They are 6-character alphanumeric codes that expire after 5 minutes.
Code Format
Section titled “Code Format”- Format:
XXXXXX— 6 uppercase alphanumeric characters, no hyphen. - Character set:
ABCDEFGHJKMNPQRSTUVWXYZ23456789 - Ambiguous characters excluded:
0,O,1,I,L(prevent visual confusion).
Pairing Flow
Section titled “Pairing Flow”- A user sends a message to the channel (e.g., your Telegram bot).
- The channel responds with a 6-character pairing code like
XK4M9Q. - The user shares this code with an admin (via email, chat, or in person).
- The admin approves the code:
- Via CLI:
evonic channel approve XK4M9Q - Via Web UI: Open the Channel Detail Modal and click Approve on the pending request.
- Via CLI:
- The user is added to the channel’s allowlist and can now interact with the agent.
Generating Codes
Section titled “Generating Codes”Admins can also generate pairing codes on demand from the Channel Detail Modal:
- Click on a channel card to open the detail modal.
- Click the Generate button in the Pairing Code section.
- A fresh 6-character code appears, valid for 5 minutes.
- Click the Copy button to share it with a user.
Code Validation
Section titled “Code Validation”Pairing codes are validated against these rules:
- Must be exactly 6 characters long.
- Must contain only uppercase letters (A-Z, excluding O, I, L) and digits (2-9).
- No hyphens, spaces, or special characters (legacy hyphen format is normalised before validation).
- Must not be expired (codes expire 5 minutes after generation).
# Example: valid codes"XK4M9Q" # ✅ Standard format"ABC123" # ✅"XK4-M9Q" # ✅ Legacy format (hyphen stripped)
# Example: invalid codes"abc123" # ❌ Lowercase"0O1L" # ❌ Contains ambiguous characters"ABCDE" # ❌ Too short (5 chars)"ABCDEFG" # ❌ Too long (7 chars)Supported Channels
Section titled “Supported Channels”| Type | Status | Library | Description |
|---|---|---|---|
| Telegram | ✅ Implemented | python-telegram-bot | Full support via bot tokens. |
| ✅ Implemented | @whiskeysockets/baileys | WhatsApp Web via Node.js sidecar (Baileys bridge). | |
| Discord | ⏳ Planned | discord.py | Coming soon. |
| Slack | ⏳ Planned | slack-sdk | Coming soon. |
Configuration
Section titled “Configuration”You can configure channels through the Web UI or directly via the API.
Via the Web UI
Section titled “Via the Web UI”- Navigate to the Agents page and select your agent.
- Click on the Channels tab.
- Click + Add Channel.
- Select the desired channel type (e.g., Telegram).
- Provide the necessary configuration (e.g., Bot Token).
- Click Add.
Channel Detail Modal
Section titled “Channel Detail Modal”Clicking on a channel card opens the Channel Detail Modal, where you can manage all aspects of the channel:
The modal provides:
- Channel Info: Name, type badge, mode toggle, and running status indicator.
- Mode Toggle: Switch between Open and Restricted mode. Toggling updates the mode immediately.
- Pending Approvals: Lists all users waiting for approval. Each entry shows the user name, external ID, pairing code, and timestamp. Click Approve or Reject to handle each request. Pending approvals auto-refresh every 30 seconds.
- Pairing Code Generator: Generate a temporary pairing code to share with a user. The code appears in large monospace text with a Copy button.
- Allowed Users: View the current allowlist with display names. Add new users by entering their
external_user_idin the input field. Remove users with the Remove button.
Via the API
Section titled “Via the API”To add a channel programmatically, send a POST request to the agent’s channel endpoint:
curl -X POST http://localhost:8080/api/agents/<agent_id>/channels \ -H 'Content-Type: application/json' \ -d '{ "type": "telegram", "name": "My Telegram Bot", "config": { "bot_token": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11", "mode": "restricted" } }'Managing Channel Mode via API
Section titled “Managing Channel Mode via API”You can update a channel’s mode by sending a PUT request:
curl -X PUT http://localhost:8080/api/agents/<agent_id>/channels/<ch_id> \ -H 'Content-Type: application/json' \ -d '{ "config": { "mode": "open" } }'Managing the Allowlist via API
Section titled “Managing the Allowlist via API”To add a user to the allowlist:
curl -X PUT http://localhost:8080/api/agents/<agent_id>/channels/<ch_id> \ -H 'Content-Type: application/json' \ -d '{ "config": { "allowed_users": ["user_id_1", "user_id_2"] } }'Primary Channels
Section titled “Primary Channels”An agent can designate one connected channel as its primary channel.
The primary channel is used for outbound notifications. For example, if an agent needs to proactively alert a user (via escalate_to_user), it will attempt to send that message through the primary channel.
Routing Priority
Section titled “Routing Priority”When an agent needs to send a message:
- If a primary channel is set and active → use it.
- Otherwise → fall back to the channel the user originally messaged from.
This ensures that if a user starts a chat on Discord, the agent responds on Discord, even if a Telegram bot is also connected.
Telegram Setup Guide
Section titled “Telegram Setup Guide”Prerequisites
Section titled “Prerequisites”- Create a bot via @BotFather on Telegram.
- Copy the API Token provided by BotFather.
- Ensure the environment has
python-telegram-botinstalled.
Configuration Fields
Section titled “Configuration Fields”| Field | Description |
|---|---|
bot_token | The unique token provided by BotFather. |
Managing the Bot
Section titled “Managing the Bot”Once configured, you can control the bot state via the API:
| Action | Method | Endpoint |
|---|---|---|
| Start Bot | POST | /api/agents/<id>/channels/<ch_id>/start |
| Stop Bot | POST | /api/agents/<id>/channels/<ch_id>/stop |
Best Practices
Section titled “Best Practices”-
Use Unique Names: When adding multiple channels of the same type, give them descriptive names (e.g., “Customer Support Telegram” vs “Internal Alert Telegram”) to avoid confusion in the UI.
-
Monitor Channel Status: Regularly check if your channels are “Running”. If a bot token is revoked or the service goes down, the channel will stop receiving messages.
-
Use Restricted Mode for Public Channels: If your channel is accessible to the public (e.g., a customer support Telegram bot), keep it in restricted mode and use pairing codes to onboard users selectively.
-
Handle Session Scoping: Sessions are keyed by
(agent_id, channel_id, external_user_id). A user having a conversation on Telegram will have a different history than that same user on Discord — this is intentional for privacy and context separation. -
Graceful Shutdown: When stopping an agent, stop its channels as well to prevent orphaned background threads or hanging connections.
Channel Management API Reference
Section titled “Channel Management API Reference”| Method | Endpoint | Description |
|---|---|---|
GET | /api/agents/<id>/channels | List all channels for an agent |
POST | /api/agents/<id>/channels | Add a new channel |
PUT | /api/agents/<id>/channels/<ch_id> | Update channel config |
DELETE | /api/agents/<id>/channels/<ch_id> | Delete a channel |
POST | /api/agents/<id>/channels/<ch_id>/start | Start the channel |
POST | /api/agents/<id>/channels/<ch_id>/stop | Stop the channel |
POST | /api/agents/<id>/channels/<ch_id>/set-primary | Set as primary channel |
POST | /api/agents/<id>/channels/<ch_id>/unset-primary | Unset as primary channel |
POST | /api/agents/<id>/channels/<ch_id>/generate-pair-code | Generate a pairing code |
GET | /api/agents/<id>/channels/<ch_id>/pending-approvals | List pending approvals |
POST | /api/agents/<id>/channels/<ch_id>/pending-approvals/<id>/approve | Approve a pending request |
POST | /api/agents/<id>/channels/<ch_id>/pending-approvals/<id>/reject | Reject a pending request |
Related Pages
Section titled “Related Pages”- Channel Approvals API — REST API and SSE for channel approvals
- CLI Channel Management — Approve pairing codes via the CLI
- Creating Channels — Technical details for implementing new channel types