Chat SDK
One channel for Telegram, Slack, Discord, Microsoft Teams and Rocket.Chat through Vercel's Chat SDK. Mentions and DMs become tasks, and results post back to the thread.
Agent Swarm can use Chat SDK as an input and output channel. One API process runs one Chat SDK instance for each configured adapter: Telegram, Slack, Discord, Microsoft Teams and Rocket.Chat. The bespoke Slack, AgentMail and Kapso integrations do not change.
The channel is off by default. A configuration change saved on the dashboard applies within a few seconds: the API restarts the adapters, with no API restart. Only a change to a boot-time environment value needs an API restart.
What it does
- Inbound on mention or DM. A bot mention or a direct message creates a task with
source: "chat". By default the Lead gets it. - Thread follow-ups. A reply in the same thread steers the running task, or becomes a follow-up task. In a Telegram group, only messages meant for the bot count: see Telegram groups.
- Who and where. Each task records the person who asked (
requestedByUserId) and starts with a[chat]line: the chat, the sender and why the bot took the message. - Results back in the thread. When a task ends, the swarm posts its output to the thread it came from.
- Attachments. Files sent with a message become task attachments.
- Tools and a skill. Agents use the
chat-*MCP tools and the built-inchat-sdkskill. - Extension hooks.
pre.chat.routecan change the routing target, andpost.chat.messageobserves traffic.
Each adapter has its own state. When one adapter fails to start, the other adapters keep running.
Telegram and Discord ran against real bots. Slack, Microsoft Teams and Rocket.Chat are experimental: they ran only against fixtures. The setup steps below may differ from what the platform shows. Issue #2149 tracks the real-app verification for Slack and Teams, #2973 for Rocket.Chat.
Configuration
The fastest path is the dashboard: Connect → Channels → Chat SDK. The card has one panel for each adapter. It saves each secret as its own secret config row named CHAT_SDK_<ADAPTER>_<FIELD> (for example CHAT_SDK_TELEGRAM_BOT_TOKEN). The JSON in CHAT_SDK_ADAPTERS then holds a reference to the row, not the secret. The card also shows the setup steps for each adapter, each webhook URL with a copy button, the adapter health, and a Register webhook button for Telegram. The setup steps start expanded, and collapse when the adapter already runs healthy.
The channel reads these keys from the environment or from global swarm config:
| Key | Value |
|---|---|
CHAT_SDK_ENABLED | true to start the channel. Default false. A saved change applies within a few seconds. |
CHAT_SDK_ADAPTERS | JSON object. Each key is an adapter name (telegram, slack, discord, teams, rocketchat), each value is the adapter config. A saved change applies within a few seconds. |
CHAT_SDK_BUFFER_MS | How long a thread collects messages before it creates one task. Default 10000 (10 s), 1 to 600000. No restart needed. |
CHAT_SDK_OWNER_WINDOW_MIN | How long after a task ends a Telegram group keeps the same owner. DMs and other adapters' threads keep theirs. Default 15, 0 to 1440. 0 keeps the owner only while the task is open. No restart needed. |
CHAT_SDK_API_URL_OVERRIDES | Environment only. JSON of platform API base URLs by adapter name, for example {"telegram":"http://127.0.0.1:8081"}. For the hosted platforms this is for development and tests only. For self-hosted Rocket.Chat it is how the instance URL is set in production. |
Secrets by reference
A value in CHAT_SDK_ADAPTERS can reference another config key as {"$config": "KEY"}:
{
"telegram": {
"botToken": { "$config": "CHAT_SDK_TELEGRAM_BOT_TOKEN" },
"secretToken": { "$config": "CHAT_SDK_TELEGRAM_SECRET_TOKEN" },
"mode": "webhook"
}
}- The API resolves references at boot from the global swarm config rows, secrets included.
- It never reads a reference from the process environment.
- It rejects reserved keys such as
API_KEY. CHAT_SDK_*rows are server-only by default (exportToEnv: false): the API reads them, agent shells never see the bot tokens.- A missing row keeps that adapter off, with the status
incompleteand the row name in the error. The other adapters start.
Switching an adapter off
The panel switch writes "enabled": false into the adapter's entry instead of removing it. The adapter stops, the values and the secret rows stay, and the card shows Off, configuration kept. Switch it on again to start it with the same values. Remove configuration deletes the entry (the secret rows stay, and are reused when the adapter is set up again).
Partial saves
An adapter entry may lack required fields. The card saves it, marks the adapter Incomplete, not running with the missing field, and starts the other adapters. This lets you store the bot token first and add the rest later. A wrong value format (a Discord public key that is not 64 hex characters, a forbidden key such as apiUrl) is still rejected on save.
For env-only deployments, put the raw values in CHAT_SDK_ADAPTERS.
The API refuses apiUrl, apiBaseUrl, baseUrl, webhookVerifier and allowUnverifiedWebhooks in this JSON. These keys could send secrets to another host or skip the signature check.
Webhook URLs
Each adapter has its own public URL:
{PUBLIC_MCP_BASE_URL}/api/integrations/chat/{adapter}/webhookThe adapter checks the platform signature on every request (Telegram secret token, Slack signing secret, Discord Ed25519 key, Teams Bot Framework token, Rocket.Chat Outgoing WebHook token). Set PUBLIC_MCP_BASE_URL to the public HTTPS address of the API.
The API rejects a webhook body above 1 MiB with 413 before the adapter reads it. Platform payloads are a few KB, and files arrive as URLs.
Local development with a tunnel
A platform cannot reach localhost. When the webhook URL on the card starts with localhost, 127.0.0.1 or [::1], the card shows a tunnel hint. To receive webhooks on a local API:
- Expose the API port with a tunnel, for example
ngrok http 3013. - Set
PUBLIC_MCP_BASE_URLto the HTTPS tunnel URL, for examplehttps://abc123.ngrok-free.app, in the API environment. Then restart the API. - Check that the card shows the tunnel URL, then register the webhook: click Register webhook for Telegram, or paste the URL in the platform settings.
When the tunnel URL changes, do steps 2 and 3 again. Telegram polling and Slack socket mode need no public URL, so they need no tunnel.
Platform setup
Telegram
- Create a bot with BotFather (
/newbot) and copy the token. - Pick a random secret token (letters, digits,
_and-, up to 256 characters). - On the Chat SDK card, turn on Telegram, enter both values, and save. The adapter starts within a few seconds.
- Click Register webhook. The API calls the Bot API
setWebhookwith the public webhook URL and the secret token. Then it shows thegetWebhookInforesult.
The bot answers the slash commands /help, /status, /cancel and /reset. The adapter publishes the list to Telegram (setMyCommands) each time it starts, so the client shows the command menu. No BotFather step is needed.
For local development without a public URL, set mode to polling. The adapter then reads updates with long polling, and no webhook is needed. Do not register a webhook in polling mode: while a webhook is set, Telegram does not deliver updates to a poller.
| Field | Required | Notes |
|---|---|---|
botToken | yes | The token from BotFather. |
secretToken | in webhook mode | Telegram sends it in the X-Telegram-Bot-Api-Secret-Token header. |
mode | no | webhook (default) or polling. |
allowedUserIds | no | Telegram user ids allowed to use the bot. Everyone is allowed when empty. |
userName | no | The bot username for mention detection. Default: the name from getMe. |
In a group with BotFather privacy mode on (the default), Telegram sends the bot only commands meant for it, replies to its messages and messages that mention it. A plain follow-up from the requester never arrives: reply to the bot or mention it. To let the bot see every group message, send /setprivacy to BotFather, turn privacy off, then remove the bot from the group and add it again.
Slack
The Chat SDK Slack adapter and the built-in Slack integration cannot run together. Set SLACK_DISABLE=true to use this adapter. Without it, the API logs the conflict at boot and starts no Chat SDK adapter. The Chat SDK card shows a Slack conflict banner.
- Create a Slack app at api.slack.com/apps.
- Add the bot scopes
app_mentions:read,channels:history,channels:read,chat:write,groups:history,groups:read,im:history,im:read,im:write,mpim:history,mpim:read,users:readandfiles:read. - Subscribe to the bot events
app_mention,message.channels,message.groups,message.imandmessage.mpim. - Pick a transport:
- Webhook mode: set the Event Subscriptions request URL to the Slack webhook URL. The adapter answers Slack's
url_verificationchallenge. Copy the signing secret. - Socket mode: turn on Socket Mode and create an app-level token (
xapp-...) withconnections:write. No public URL is needed.
- Webhook mode: set the Event Subscriptions request URL to the Slack webhook URL. The adapter answers Slack's
- Install the app to the workspace and copy the bot token (
xoxb-...). - Optional: under Slash Commands, create
/help,/status,/canceland/reset. In webhook mode the request URL is the Slack webhook URL. In socket mode the commands arrive over the socket. See Slash commands.
To create the app from a manifest (Create New App, then From a manifest), start from this minimal one. Replace ${PUBLIC_MCP_BASE_URL} with the public URL of your API.
This manifest is unverified against a real app. Adjust the scopes to your needs.
display_information:
name: Agent Swarm
features:
bot_user:
display_name: swarm
always_online: true
# Optional. Webhook mode only: each url is the Slack webhook URL. In socket mode, remove the url lines.
slash_commands:
- command: /help
description: List the commands
url: ${PUBLIC_MCP_BASE_URL}/api/integrations/chat/slack/webhook
- command: /status
description: Show the latest task of this chat
url: ${PUBLIC_MCP_BASE_URL}/api/integrations/chat/slack/webhook
- command: /cancel
description: Cancel the running task of this chat
url: ${PUBLIC_MCP_BASE_URL}/api/integrations/chat/slack/webhook
- command: /reset
description: "Start over: the next message gets no earlier context"
url: ${PUBLIC_MCP_BASE_URL}/api/integrations/chat/slack/webhook
oauth_config:
scopes:
bot:
- app_mentions:read
- channels:history
- channels:read
- chat:write
- groups:history
- groups:read
- im:history
- im:read
- im:write
- mpim:history
- mpim:read
- users:read
- files:read
settings:
event_subscriptions:
# Webhook mode only. In socket mode, remove request_url.
request_url: ${PUBLIC_MCP_BASE_URL}/api/integrations/chat/slack/webhook
bot_events:
- app_mention
- message.channels
- message.im
# Add message.groups and message.mpim for private channels and group DMs (step 3).
# Socket mode: set this to true and create an app-level token with connections:write.
socket_mode_enabled: false| Field | Required | Notes |
|---|---|---|
botToken | yes | The bot token (xoxb-...). |
mode | no | webhook (default) or socket. |
signingSecret | in webhook mode | The app signing secret. |
appToken | in socket mode | The app-level token (xapp-...). |
userName | no | The bot name. Default: the name from auth.test. |
Discord
-
Create an application in the Discord Developer Portal. Copy the Application ID and the Public Key (64 hex characters).
-
On the Bot page, copy the bot token and turn on the Message Content privileged intent.
-
Invite the bot to your server. The card shows the invite link once the Application ID is entered. By hand, open this URL with your application id:
https://discord.com/oauth2/authorize?client_id=APPLICATION_ID&scope=bot+applications.commands&permissions=326417632320The permissions integer
326417632320is View Channels, Send Messages, Send Messages in Threads, Create Public Threads, Manage Threads, Read Message History, Add Reactions, Attach Files and Embed Links. A bot that is connected but in no server never receives a message; the card says "Running, in no server" in that case and lists the servers otherwise. -
Optional, for slash commands: set Interactions Endpoint URL to the Discord webhook URL. Discord sends slash commands only to this URL, never over the Gateway. Then register the commands once. Replace the application id and the bot token:
curl -X PUT "https://discord.com/api/v10/applications/${APPLICATION_ID}/commands" \ -H "Authorization: Bot ${BOT_TOKEN}" -H "Content-Type: application/json" \ -d '[ {"name":"help","description":"List the commands"}, {"name":"status","description":"Show the latest task of this chat"}, {"name":"cancel","description":"Cancel the running task of this chat"}, {"name":"reset","description":"Start over: the next message gets no earlier context"} ]'Global commands can take up to an hour to appear in the client. Without the endpoint URL the bot still answers messages and mentions.
| Field | Required | Notes |
|---|---|---|
botToken | yes | The bot token. |
publicKey | yes | The application public key, 64 hex characters. |
applicationId | yes | The application id. |
respondToChannelIds | no | Channel ids where the bot answers every message, not only mentions. |
respondToGlobalMentions | no | true to answer @everyone and @here. |
mentionRoleIds | no | Role ids that count as a mention of the bot. |
userName | no | The bot name. |
Discord sends channel messages and mentions only over the Gateway WebSocket, not over the webhook. The API runs a Gateway listener for the whole life of the process. See Limits for the gaps.
Microsoft Teams
Experimental. The Teams adapter has not run against a real tenant yet (#2149).
- Create an Azure Bot resource. Pick Multi Tenant or Single Tenant.
- Copy the Microsoft App ID, and create a client secret for it.
- For a single-tenant bot, copy the tenant id.
- Set the bot's Messaging endpoint to the Teams webhook URL.
- Add the Microsoft Teams channel to the bot, and install the bot in Teams.
- Optional: to let agents read thread history with
chat-read-thread, grant the app a Microsoft GraphChat.Read.*permission (see Limits).
| Field | Required | Notes |
|---|---|---|
appId | yes | The Azure Bot app (client) id. |
appPassword | yes | The app client secret. |
appType | no | MultiTenant (default) or SingleTenant. |
appTenantId | for SingleTenant | The Entra tenant id. |
userName | no | The bot name. |
A Teams thread id contains the service URL of the conversation, and the adapter sends the bot token to that URL. The swarm sends only to Bot Framework service hosts: smba.trafficmanager.net, smba.infra.gcc.teams.microsoft.com, smba.infra.gov.teams.microsoft.us, smba.infra.dod.teams.microsoft.us and msteams.botframework.azure.cn, over HTTPS. The webhook refuses an activity with a different serviceUrl (HTTP 403). chat-post, chat-reply, chat-read-thread, chat-open-dm and the result relay refuse such an id and send nothing. In tests, the origin of the teams entry in CHAT_SDK_API_URL_OVERRIDES is also allowed.
Rocket.Chat
Experimental. The Rocket.Chat adapter has not run against a real server yet (#2973).
Rocket.Chat is self-hosted, so each deployment has its own instance URL. It is not an adapter field: a base URL in CHAT_SDK_ADAPTERS could send a saved token to another host, so the API rejects baseUrl there like every other base-URL key. Set the instance in the API's environment instead, and restart the API:
CHAT_SDK_API_URL_OVERRIDES='{"rocketchat":"https://chat.example.com"}'Use the instance's final URL. The adapter does not follow HTTP redirects, so a URL that redirects (for example http:// to https://) fails every REST call.
Until it is set, the adapter card shows the missing variable instead of starting.
- Create a user for the bot, or use an existing one, and note its username.
- As that user, open My Account → Personal Access Tokens, generate a token, and copy both the token and the user id shown with it.
- In Administration → Workspace → Integrations, create an Outgoing WebHook with event type Message Sent.
- Point its URLs at the Rocket.Chat webhook URL, and leave Trigger Words empty to receive every message in the selected channels.
- Copy that integration's Token into
webhookToken.
| Field | Required | Notes |
|---|---|---|
token | yes | The bot account's personal access token. Sent on every REST call. |
botUserId | yes | The user id shown with the token. Also identifies the bot's own messages. |
webhookToken | yes | The Outgoing WebHook Token. Checked on every webhook call. |
userName | yes | The bot account's username, without the @. |
The adapter verifies the token field of each webhook payload against webhookToken with a timing-safe comparison, and answers 401 when it does not match. A mention is matched by looking for @<userName> in the message text, and the REST API has no call that reports the bot's own name, so userName is required here while it is optional for the other adapters: a wrong one means the bot never answers. The REST API has no typing endpoint either, so the bot shows no typing indicator on Rocket.Chat.
How it works
-
Buffer. A mention or a DM opens a thread buffer. More messages in the same thread join it for
CHAT_SDK_BUFFER_MS(10 s by default). A message that starts with!nowflushes the buffer at once. One flush creates one task. -
Route. The router picks a target in this order: a
swarm#<agentId>token in the text,swarm#all(every reachable agent), a channel mapping fromregister-chat-channel(an agent, or a workflow when the message mentions the bot or is a DM, so a plain reply in a subscribed thread never starts a second run), the agent that owns the thread (in a Telegram group, only while its task is open and forCHAT_SDK_OWNER_WINDOW_MINafter it ends), and then the Lead for a mention or DM. Apre.chat.routeextension can change the target. -
Task. The task gets
source: "chat"and a context keytask:chat-sdk:{adapter}:{encoded thread id}. Later tasks in the same thread share the key. The task text starts with a header such as[chat] telegram · supergroup "Life" · from: Taras (@tarasyarema) · addressed: reply-to-bot, then the recent thread messages. Message text reaches the agent as markdown: link URLs ([text](url)), inline code and code fences survive, on every platform.addressedisdm,mention,reply-to-bot,requester-follow-upornone. The sender is resolved through the user registry as the<adapter>identity kind with the platform user id (for Telegram,telegramandfrom.id). A known sender becomes the task'srequestedByUserId, so times and per-user preferences apply. An unknown sender appears in the People page Unmapped tab; link it there. -
Steer or follow up. When the Lead's task for the thread is in progress, a new plain reply steers that task. On Telegram the bot reacts ✍ to it; other adapters get a short text acknowledgement. Otherwise the reply waits in the buffer and becomes a follow-up task that depends on the previous one.
-
Attachments. Files are downloaded once per flush and attached to each new task. A file over the inbound cap (20 MB on Telegram, the most a bot can download; 50 MB elsewhere) is skipped: the task text says so, and the bot replies in the thread naming the file. Audio files and voice notes are transcribed into the task text when transcription is configured (see Voice notes), and the audio stays attached.
-
Relay. When a task ends (completed, failed or cancelled), a database trigger records a relay obligation. A watcher posts the task output to the thread and marks the row delivered. Lead follow-up tasks on the same thread are relayed too, so delegated results reach the user. When a Lead task is resumed after a shutdown or a crash, the resume task relays the final answer. A worker task, or its resume, does not relay: its result reaches the thread through the Lead follow-up. A task that calls
defer-taskposts nothing when it defers; its wake-up task keeps the chat thread and relays the real answer./status,/cancel, steering and follow-ups treat that wake-up as the thread's chat task. Only the deferring agent's own wake-up keeps the thread: a delegated worker's deferral, or one re-targeted to another agent, wakes up outside the chat, and its result still reaches the thread through the Lead follow-up. Only the deferring agent or a lead can change a deferral's schedule. A failed post retries with backoff, up to 10 minutes between tries. After 24 hours the swarm stops and records the last error. Delivery is at least once: a crash between the post and the record can send a message twice. -
Typing. The bot shows the typing indicator from the first buffered message until it posts the reply. The indicator stops when the flush creates no task, and it stops after 15 minutes at most.
-
Reactions (Telegram). The ask shows the task state as one reaction that changes: 👀 when the bot takes the message (⚡ for
!now), then 👍 when the answer posts, or 👎 for a failed or cancelled task. A steering message gets ✍. A bot can set one reaction per message, and only emoji from the Bot APIReactionTypeEmojilist, which has no ✅ or ❌. In a batch of buffered messages, only the newest one, which the answer replies to, keeps the reaction. When the flush creates no task, the reactions are removed. A reaction the platform refuses, such as a400 REACTION_INVALIDin a group whose admins limit reactions, is logged and never blocks the answer or the task.To get the text steering acknowledgement on a Telegram channel as well, store
{ "textAcks": true }under the channel id (for exampletelegram:-100123) in the KV namespaceintegrations:chat:channel-settings:kv-set namespace="integrations:chat:channel-settings" key="telegram:-100123" value={"textAcks": true} -
Shutdown. On API shutdown the channel stops inside one 10 s budget. First, webhooks answer
503and refuse new work. Then the relay watcher stops claiming rows. Next, in-flight handlers finish and every waiting thread buffer becomes its task. Then the swarm waits for a relay post that is still in flight. Last, the adapters shut down. Each step gets only the time that is left. A step that runs out of time is abandoned and logged asShutdown budget spent, abandoned: ....- Relay post. An abandoned post keeps its claimed row, which stays pending. After the restart, the row is sent again after the normal backoff (up to 10 minutes), within the 24 hour limit. If the platform did accept the abandoned post, the user can see the message twice.
- Buffered messages. Thread buffers exist only in API memory, not in the Chat SDK tables. The platform already got its webhook acknowledgement, so it does not send those messages again. If the flush runs out of time, the threads not yet turned into tasks are lost, and the log line says so.
Every answer starts with a task tag: the short task id that /status shows and the agent name, for example #a3f2b1c9 · Coder. On Telegram the answer, chat-reply posts, and text steering acknowledgements reply to the message they answer, so the client quotes the ask. A lead follow-up, a resume and a defer wake-up reply to the original ask. If the ask was deleted, the answer still arrives, without the quote. Slack, Discord and Teams post without a reply anchor.
Long output is split into several messages at the platform limit. On Telegram, an answer longer than 1,000 characters is collapsed: a short first paragraph stays visible, and the rest goes into a <details> block the reader expands. This needs Bot API 10.1 rich messages. On an older Bot API server the block markup shows as text. The relay also sends the files an agent attached to the task (with store-progress or an upload), after the text. Files the user sent the bot are not echoed back.
Telegram groups
In a Telegram group or supergroup, the bot takes a message only when it is meant for the bot: it mentions the bot, it replies to one of the bot's messages, or its sender asked for the thread's task and the owner window is open. Everything else is side chatter. It neither steers the running task nor creates a task. A swarm#<agentId> or swarm#all token, or an agent channel mapping, still routes any message. A reply to the bot counts as a mention whatever TELEGRAM_MENTION_ON_REPLY says. DMs and other adapters' threads are unchanged.
Voice notes
Voice notes and other audio files are transcribed through ElevenLabs /speech-to-text, OpenAI /audio/transcriptions, or Groq's OpenAI-compatible endpoint. Self-hosted whisper servers work with openai. Deepgram and AssemblyAI are not supported. Configure it under Connect → AI providers → Transcription, which also shows the active provider and where its key came from.
Transcription picks its key in this order:
TRANSCRIPTION_API_KEY, withTRANSCRIPTION_PROVIDER(defaultopenai). Store it as a secret. Only the API server reads it: it is never exported to agent env or scripts, and the config API does not list it.- Without it, a provider key the API server already has. A set
TRANSCRIPTION_PROVIDERuses only its own key. Otherwise the first one set wins:ELEVENLABS_API_KEY, thenOPENAI_API_KEY, thenGROQ_API_KEY. - No key: transcription is off.
The API server reads global config rows and its own deployment env. A provider key stored only at agent or repo scope is not seen.
| Key | Default | What it does |
|---|---|---|
TRANSCRIPTION_API_KEY | unset | Explicit key. Overrides the auto-detected provider key. |
TRANSCRIPTION_PROVIDER | auto-detect (openai with an explicit key) | elevenlabs sends xi-api-key and model_id; openai and groq send Authorization: Bearer and model. |
TRANSCRIPTION_BASE_URL | https://api.elevenlabs.io/v1, https://api.openai.com/v1 or https://api.groq.com/openai/v1 | Base URL of the service, for an explicit TRANSCRIPTION_API_KEY only. An auto-detected key always goes to its own provider. |
TRANSCRIPTION_MODEL | scribe_v2, whisper-1 or whisper-large-v3-turbo | Model name sent to the service. |
The task text then carries a [Transcript of <file>] block under the file line. Without a key, the task text gets one line saying no transcription provider is configured. A failed call is noted the same way, and the task is still created.
The same keys transcribe audio shared with the Slack bot and audio attached in the dashboard's session composer, including clips recorded with its mic button (webm in Chrome and Firefox, m4a in Safari).
Slash commands
One handler answers the commands on every adapter that delivers them: Telegram, Slack and Discord. Teams has no slash commands. A command creates no task and is not part of the thread context. An unknown command (/deploy) gets the command list back, so no /word message is dropped. Telegram's /start, sent when a user opens the bot DM, gets a welcome and the command list; it is not in the / menu.
| Command | What it does |
|---|---|
/help | Lists the commands. |
/status | Shows the latest task of the chat: short id, status, and the agent it is assigned to. |
/cancel | Cancels every pending or in-progress task of the chat, newest first, up to 20. The relay posts the cancellation like any other task end. |
/reset | Starts a new conversation. The next message creates a task with no parent task and no thread history older than the reset. A running task keeps running: send /cancel to stop it. The mark lives in the swarm database for 30 days. |
The command acts on the chat it is typed in: a Telegram private chat or group, a Slack channel or DM, a Discord channel. Slack and Discord tasks belong to a thread (a Slack thread root, the Discord thread opened for a mention), and a slash command in the channel names no thread. So /status and /reset act on the thread of the sender's most recent task in the channel, and /cancel on the sender's most recent running one, one thread per call. Only tasks the sender requested count, in every channel-level command: /status shows, /cancel cancels and /reset marks only the sender's own tasks, also in a thread that others asked in and in a Discord channel that holds the task itself (Discord does this when it cannot open a thread). /reset leaves a thread untouched when someone else also asked in it, since the mark covers the whole thread. A sender with no linked user (People page) gets no target. Telegram chats, a Discord thread and a DM act on the whole conversation. Typed inside a Discord thread, the command acts on that thread. The shipped Slack manifest declares /agent-swarm-status and /agent-swarm-help; with the Chat SDK adapter they run /status and /help. Declare /agent-swarm-cancel and /agent-swarm-reset the same way to get the other two.
Each platform learns the list in its own way. Telegram: the adapter calls setMyCommands at every start. Slack: the app manifest (or the Slash Commands page) lists the commands. Discord: a one-time application-command registration plus the Interactions Endpoint URL. The platform steps above show each one.
Tools
Agents get these tools when the channel is on (capability chat-sdk). The parameters are in MCP.md in the repository.
| Tool | What it does |
|---|---|
chat-reply | Post to the thread of the current chat task. Use it for a question, a progress note, or to send files. The final output posts by itself. |
chat-post | Lead only. Post to any thread or channel id (for example telegram:12345 or topic telegram:-100123:42). A channel-only post uses its registered default topic when set. |
chat-read-thread | Read the recent messages of a thread, oldest first. Every agent can read the thread of its current task. Other threads are lead only. |
chat-open-dm | Lead only. Open or find the direct-message thread with a user. |
register-chat-channel | Lead only. Route a channel to a fixed agent or workflow. Optionally set defaultThreadId for Telegram channel-only posts. |
unregister-chat-channel | Lead only. Remove that mapping. |
To give a Telegram channel a default topic, call register-chat-channel with adapter: "telegram", channelId: "telegram:-100123", an agentId or workflowId, and defaultThreadId: "telegram:-100123:42". The topic ID must be a positive integer and belong to that channel. A chat-post with only that channelId goes to topic 42; an explicit threadId takes precedence, including the base chat ID to post to General. chat-reply and automatic task answers stay in their task's thread. Re-registering replaces the mapping, so omit defaultThreadId to clear the default, or use unregister-chat-channel to remove the whole mapping. This setting does not create topics.
chat-reply and chat-post take an optional attachments list of up to 10 entries: an attachment id of the current task, or a path in the swarm agent-fs drive (the local file store when agent-fs is not configured). The files go out after the text. Telegram sends JPEG and PNG as photos, MP4 as video, MP3 and M4A as audio, and anything else as a document. Two to ten files of one kind go as one media group. Slack, Discord and Teams get the files as uploads on one message.
A worker gets thread access only through a chat task that it is assigned or created. send-task and POST /api/tasks refuse a parentTaskId that a non-lead agent neither owns nor created, so a child task cannot inherit a foreign thread.
The chat-sdk skill is seeded for every agent, so there is nothing to install. It covers formatting per platform, reply etiquette and thread ids.
Extensions
| Event | When | Use |
|---|---|---|
pre.chat.route | A thread buffer flushes, before task creation. | Change the target to an agent, the Lead, a broadcast or a workflow. Block it to drop the messages. |
post.chat.message | A message is received (before buffering) or sent. | Observe traffic. direction is inbound or outbound. |
Payloads and examples: Extensions guide.
Limits
| Platform | Message length | History for chat-read-thread |
|---|---|---|
| Telegram | 4096 characters | No history API. The swarm keeps the last 100 messages of a thread for 7 days in its database. |
| Slack | 4000 characters | Platform history. |
| Discord | 2000 characters | Platform history. |
| Teams | 20000 characters | Microsoft Graph, needs the Chat.Read.* permission. |
| Rocket.Chat | 5000 characters (the Message_MaxAllowedSize default) | Platform history (rooms.history, chat.getThreadMessages). |
Outbound files are capped per file: Telegram 50 MB (an image over 10 MB goes as a document), Discord 10 MB, Slack and Teams 50 MB (the swarm reads a file into memory before it sends it). A file over the cap, a file that cannot be read, or a file the platform refuses is not sent. The thread then gets a Could not send ... note that names the file and the reason, and the tool result lists it in unsentFiles.
Platform notes:
- Discord Gateway gaps. The Gateway listener runs in windows of 6 hours and re-arms itself after each window. Discord does not replay messages from a gap. A message sent during a re-arm, or while the listener waits 30 s after a failure, is lost. A bad bot token keeps the adapter health
ok(the interactions webhook still works), and the Gateway state showsbackoff. - Telegram. A bot can message a user only after the user started a chat with it. A webhook needs a public HTTPS URL on port 443, 80, 88 or 8443.
- Slack. No rich rendering (blocks, cards, streaming edits) in this version.
- Teams. The Teams SDK writes its own logs, which do not go through the swarm secret scrubber. The adapter has no slash commands.
- Rocket.Chat. No typing indicator: the REST API has no endpoint for it. No slash commands, no outbound file uploads, and inbound attachments are not downloaded. Cards and buttons post as their fallback text.
- Unsubscribed group threads. In a group thread, the bot subscribes when the first task is created. A reply without a mention inside the first buffer window is not seen.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| The card shows Not running for a saved adapter. | The adapter is still starting, or the last save is still applying. Refresh in a few seconds. |
| The card shows Failed to start with an error. | The adapter failed to initialize (bad token, network error). Fix the value and save. A save with no change does not restart the adapter, so restart the API to retry a network error. |
| Configuration error on the card. | CHAT_SDK_ADAPTERS is not valid JSON, fails the schema, or references a missing or reserved $config key. |
| Slack conflict on the card, and no adapter starts. | CHAT_SDK_ADAPTERS has slack and SLACK_DISABLE is not true. Set SLACK_DISABLE=true or remove the Slack adapter. |
The webhook answers 404. | The channel is off, the adapter is not in CHAT_SDK_ADAPTERS, or the adapter is still initializing after a restart or a save. |
The webhook answers 503. | The adapter failed to start, a save is restarting the adapters, or the API is shutting down. Check the card or the API boot log ([chat-sdk] lines). |
The Slack webhook answers 405. | The Slack adapter runs in socket mode, which needs no request URL. Remove the URL from the Slack app, or switch to webhook mode. |
| Telegram gets no updates. | In webhook mode, click Register webhook and check last_error_message in the result. In polling mode, make sure no webhook is registered. |
| Discord mentions create no task. | Turn on the Message Content intent, and check the Gateway state on the card. |
| Discord slash commands do nothing. | Set the Interactions Endpoint URL and register the commands (Discord step 4). Global commands can take up to an hour to show up. |
| A follow-up task has no thread context after a restart or a save. | Fixed: the swarm merges the history it persisted with the adapter's memory. If it still happens on Telegram, check that the chat_lists table holds msg-history: rows for the thread. |
Reference
- Chat SDK and its repository.
- Status API:
GET /api/integrations/chat/status. Telegram registration:POST /api/integrations/chat/telegram/register-webhook(Lead or dashboard user). - Seeded skill:
templates/skills/chat-sdk/content.mdin this repository.
Kapso (WhatsApp)
Inbound WhatsApp messages become swarm tasks via Kapso; agents reply in-thread. Native webhook handler, KV-backed number routing, outbound send/reply MCP tools, and the kapso-whatsapp skill for everything beyond plain text.
Composio
Tool Router sessions, connected accounts, Connect Links, and the Agent Swarm x route for third-party app tools.