9.4. Multi-Channel Messaging¶
Multi-Channel Messaging lets your agents respond to messages from external chat platforms — Telegram, Slack, Discord, and WhatsApp. Once configured, messages sent to your bot are routed to the appropriate Squad group for processing, and the agent's reply is sent back through the same channel.
Architecture¶
flowchart LR
subgraph Channels
TG[Telegram]
SL[Slack]
DC[Discord]
WA[WhatsApp]
end
subgraph Backend.AI GO
CR[Channel Registry]
AL[Sender Allowlist]
MR[Message Router]
SQ[Squad Groups]
end
TG & SL & DC & WA --> CR
CR --> AL
AL -- allowed --> MR
AL -- blocked --> X[Rejected]
MR --> SQ
SQ --> MR
MR --> TG & SL & DC & WA General Setup Process¶
For each channel:
- Create a bot or app in the platform's developer portal
- Copy the required tokens/credentials
- Connect the channel in Backend.AI GO
- Map the channel's chats to Squad groups
- (Optional) Configure the sender allowlist
Telegram¶
Create a Telegram Bot¶
-
Open Telegram and start a chat with @BotFather.
-
Send
/newbotand follow the prompts:- Choose a display name (e.g., "My AI Assistant")
- Choose a username ending in
bot(e.g.,myai_assistant_bot)
-
BotFather replies with your Bot Token (format:
1234567890:ABCdef...). Copy it.
Connect Telegram in Backend.AI GO¶
-
Go to Settings > Channels > Telegram.
-
Paste your Bot Token into the token field.
-
Click Validate Token to verify the token is valid.
-
Click Connect.
-
The status indicator turns green when the bot is connected.
Telegram Trigger Behavior¶
| Chat Type | Trigger |
|---|---|
| Direct message (DM) | All messages trigger the bot |
| Group chat | Messages that @mention the bot trigger it |
JID Format¶
Telegram chat identifiers use the format tg:{chat_id} (e.g., tg:123456789).
Slack¶
Create a Slack App¶
-
Go to api.slack.com/apps and click Create New App.
-
Choose From scratch, enter an app name and select your workspace.
-
In the left sidebar, click OAuth & Permissions.
-
Under Bot Token Scopes, add these scopes:
app_mentions:readchannels:historychat:writegroups:historyim:historyim:readim:write
-
Click Install to Workspace and authorize. Copy the Bot User OAuth Token (
xoxb-...). -
In the left sidebar, click Socket Mode and enable it. Create an App-Level Token with
connections:writescope. Copy the App Token (xapp-...). -
Under Event Subscriptions, enable events and subscribe to:
app_mentionmessage.im
Connect Slack in Backend.AI GO¶
-
Go to Settings > Channels > Slack.
-
Paste your Bot Token (
xoxb-...) and App Token (xapp-...). -
Click Validate Tokens to verify both tokens.
-
Click Connect.
Slack Trigger Behavior¶
| Event | Trigger |
|---|---|
app_mention | @mentioning the bot in a channel |
message.im | Any direct message to the bot |
JID Format¶
Slack chat identifiers use the format slack:{channel_id} (e.g., slack:C01234567).
Discord¶
Create a Discord Bot¶
-
Go to the Discord Developer Portal and click New Application.
-
Give it a name and click Create.
-
Click Bot in the left sidebar.
-
Click Add Bot and confirm.
-
Under Token, click Reset Token and copy the token.
-
Under Privileged Gateway Intents, enable:
- Message Content Intent (required to read message text)
-
Click OAuth2 > URL Generator. Under Scopes, select
bot. Under Bot Permissions, select:Read Messages/View ChannelsSend MessagesRead Message History
-
Copy the generated OAuth2 URL and open it in a browser to invite the bot to your server.
Connect Discord in Backend.AI GO¶
-
Go to Settings > Channels > Discord.
-
Paste your Bot Token.
-
Click Validate Token.
-
Click Connect.
Discord Trigger Behavior¶
| Chat Type | Trigger |
|---|---|
| Guild text channel | @mentioning the bot |
| Direct message | All messages trigger the bot |
JID Format¶
Discord chat identifiers use the format discord:{channel_id} (e.g., discord:123456789012345678).
WhatsApp Business¶
WhatsApp uses the WhatsApp Business Cloud API and requires a verified Meta business account.
Prerequisites¶
- A Meta Developer Account
- A WhatsApp Business Account
- A phone number dedicated to the WhatsApp Business API
Configure WhatsApp Business API¶
-
Go to developers.facebook.com and create a new app of type Business.
-
Add the WhatsApp product to your app.
-
In the WhatsApp setup, note your:
- Phone Number ID (numeric ID of your WhatsApp phone number)
- WhatsApp Business Account ID
-
Generate a Permanent Access Token (or a temporary token for testing):
- Go to Meta Business Suite > System Users
- Create a system user with
whatsapp_business_messagingpermission - Generate a token for the system user
-
Configure the Webhook:
- Webhook URL:
https://{your-domain}/api/v1/channels/whatsapp/webhook - Verify Token: any string you choose (used during webhook verification)
- Subscribe to
messagesevents
- Webhook URL:
Public Webhook Required
WhatsApp requires a publicly accessible HTTPS webhook URL. Use a reverse proxy (nginx, Caddy) or a tunneling service (ngrok, Cloudflare Tunnel) to expose Backend.AI GO's Management API.
Connect WhatsApp in Backend.AI GO¶
-
Go to Settings > Channels > WhatsApp.
-
Fill in:
- Phone Number ID: Your WhatsApp phone number ID
- Access Token: Your permanent access token
- Webhook Verify Token: The verify token you set in Meta's developer portal
-
Click Validate Configuration.
-
Click Connect.
-
Trigger the webhook verification from Meta's developer portal by clicking Verify and Save.
WhatsApp Trigger Behavior¶
All incoming direct messages trigger the bot. Group messages are supported when the phone number is added to the group.
JID Format¶
WhatsApp chat identifiers use the format wa:{phone_number} (e.g., wa:15551234567).
Managing Connected Channels¶
View Channel Status¶
Response:
{
"channels": [
{"name": "telegram", "connected": true, "statusMessage": "Connected"},
{"name": "slack", "connected": true, "statusMessage": "Connected"},
{"name": "discord", "connected": false, "statusMessage": "Not configured"},
{"name": "whatsapp", "connected": false, "statusMessage": "Not configured"}
]
}
Disconnect a Channel¶
-
Go to Settings > Channels > {Channel Name}.
-
Click Disconnect.
Send a Message¶
curl -X POST http://localhost:55765/api/v1/channels/messages \
-H "Content-Type: application/json" \
-d '{"chatJid": "tg:123456789", "content": "Hello from Backend.AI GO!"}'
View Message History¶
# List all chats
curl http://localhost:55765/api/v1/channels/chats
# Get messages from a specific chat
curl "http://localhost:55765/api/v1/channels/chats/tg:123456789/messages?limit=50"
Sender Allowlist¶
The sender allowlist restricts which external users can interact with your agents. When configured, messages from senders not on the list are silently dropped.
Configure via Management API¶
curl -X PUT http://localhost:55765/api/v1/channels/sender-allowlist \
-H "Content-Type: application/json" \
-d '{
"enabled": true,
"entries": [
{"chatJid": "tg:123456789", "label": "Alice"},
{"chatJid": "slack:U01ABCDEF", "label": "Bob"}
]
}'
Behavior¶
| Allowlist State | Incoming Message | Action |
|---|---|---|
| Disabled | Any | Process and route |
| Enabled | Sender on list | Process and route |
| Enabled | Sender not on list | Drop silently |
Next Steps¶
- Channel-Squad Mapping — Route messages to specific squad groups
- Security Model — Understand the security layers