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.
Agent Swarm integrates with Kapso — a WhatsApp platform vendor that fronts the Meta Cloud API — as an inbound chat source. A provisioned WhatsApp number's inbound messages become swarm tasks, and agents reply in-thread over WhatsApp.
The Kapso MCP tools (register-kapso-number, unregister-kapso-number, send-whatsapp-message, reply-whatsapp-message) require the kapso capability, which is disabled by default. Enable it by setting CAPABILITIES on the API server to the full default list plus kapso — the variable replaces the defaults, it is not additive. See the environment variables reference. The inbound webhook handler is not gated by this flag.
The thin send-whatsapp-message / reply-whatsapp-message MCP tools cover the common text path. Everything else — templates, media, reactions, typing indicator, mark-as-read, signature verification, contact resolution, conversation history — lives in the kapso-whatsapp skill (shipped as a template skill in this repo). Drop to the skill's REST recipes for those.
What it does
- Inbound on message. A provisioned number's webhook is pointed at the swarm's native handler. An inbound
whatsapp.message.receivedevent becomes akapso-inboundtask (or is dispatched to a workflow, if the number maps to one). - KV-backed routing, no table. The phone-number → routing mapping lives in the swarm KV store (
integrations:kapso:numbers), written by the lead-onlyregister-kapso-numbertool. No migration required. - Webhook signing + dedup. Inbound deliveries are HMAC-SHA256 verified against
KAPSO_WEBHOOK_HMAC_SECRET(X-Webhook-Signatureheader) and deduped by message id (integrations:kapso:dedupe, 24h TTL). - Default routing to the lead. When a number is registered without an explicit agent or workflow, inbound tasks route to the lead agent.
- Outbound tools.
send-whatsapp-messageandreply-whatsapp-messagewrap the Kapso Meta-proxy text send (the latter quote-replies an inbound WAMID).
Setup
1. Configure environment
Add these as swarm config values in the integrations dashboard, or set them in your .env for a self-hosted deployment:
# Required — Kapso API key (X-API-Key header)
KAPSO_API_KEY=your-kapso-api-key
# Required — the WhatsApp Business phone-number ID the swarm sends from
KAPSO_PHONE_NUMBER_ID=123456789012345
# Recommended — shared secret Kapso signs inbound webhooks with (X-Webhook-Signature, raw hex)
KAPSO_WEBHOOK_HMAC_SECRET=your-webhook-secret
# Optional — override the Kapso API base URL (defaults to https://api.kapso.ai)
# KAPSO_API_BASE_URL=https://api.kapso.ai2. Register the number
Provisioning is a lead-only operation. The lead calls the register-kapso-number MCP tool, which:
- Points the number's Kapso webhook at
<MCP_BASE_URL>/api/integrations/kapso/webhook(signed withKAPSO_WEBHOOK_HMAC_SECRET). This step is idempotent — an identical existing webhook is detected and not re-created. - Writes the routing mapping to KV so inbound messages route to an agent (defaults to the lead) or a workflow.
The tool also accepts optional agentId, workflowId, and name fields so you can route a number to a specific agent target, dispatch it through a workflow trigger, and label the mapping for operators.
To stop routing, the lead calls unregister-kapso-number (also lead-only). The Kapso-side webhook is not deleted automatically — remove it in the Kapso dashboard if you want deliveries to stop.
3. Install the skill
The kapso-whatsapp skill is the canonical reference for any WhatsApp interaction beyond plain text. It ships as a template skill at templates/skills/kapso-whatsapp and is recommended (auto-installable) on the integration's dashboard card.
How it works
Two inbound paths exist:
- Native handler (
/api/integrations/kapso/webhook) — fires for any phone number registered viaregister-kapso-number. Verifies HMAC, dedupes by message id, reads the routing mapping from KV, and either dispatches akapso-inboundtask or delegates to a workflow trigger. Also emits akapso.message.receivedevent on the workflow event bus (additive — event-subscribed workflows can observe inbound regardless of mapping). - Workflow path — a number whose mapping points at a
workflowIddispatches inbound via that workflow's webhook trigger instead of creating a task directly.
The kapso-inbound task description is rendered from the kapso.message.received prompt template, so operators can customize the triage instructions without code changes.
Inbound events are filtered to message.kapso.direction == "inbound" — the swarm's own outbound sends, deliveries, reads, and failures do not create tasks.
Outbound updates
- Text (common case):
send-whatsapp-message/reply-whatsapp-messageMCP tools. Free-form text is only allowed within the 24h WhatsApp session window; outside it the tool returns a structuredsessionWindowExpirederror pointing at the template path. - Provisioning / teardown:
register-kapso-numberandunregister-kapso-numberare the lead-only MCP tools for turning native routing on or off for a specific phone-number ID. - Everything else: the
kapso-whatsappskill's REST recipes — templates (outside the 24h window), media (image / document / audio / video), reactions, typing indicator, mark-as-read, signature verification, contact resolution, and conversation history.
Reference
- Kapso — platform vendor.
kapso-whatsappskill —templates/skills/kapso-whatsapp/SKILL.mdin this repo.
AgentMail Integration
Set up AgentMail to give each agent its own email inbox for receiving newsletters, notifications, and external messages
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.