integrate-whatsapp
Connect WhatsApp to your product with Kapso: onboard customers with setup links, detect connections, receive events via webhooks, and send messages/templates/media. Also manage WhatsApp Flows (create/update/publish, data endpoints, encryption). Use when integrating WhatsApp end-to-end.
By gokapso · 3,731 installs
npx skills add gokapso/agent-skills --skill integrate-whatsapp
Source repository · Upstream listing
Integrate WhatsApp
Setup
Preferred path:
Kapso CLI installed and authenticated ( kapso login )
Use kapso status to confirm project access before onboarding or messaging
Fallback path:
Env vars:
KAPSO API BASE URL (host only, no /platform/v1 )
KAPSO API KEY
META GRAPH VERSION (optional, default v24.0 )
Auth header (direct API calls):
Install deps (once):
Connect WhatsApp (setup links)
Preferred onboarding path (CLI):
1. Start onboarding: kapso setup
2. If setup is blocked, resolve context with:
kapso projects list
kapso projects use <project id
kapso customers list
kapso customers new name "<customer name " external id <external id
kapso setup customer <customer id
3. Complete the hosted onboarding URL
4. Confirm connected numbers: kapso whatsapp numbers list output json
5. Resolve the exact number you want to operate: kapso whatsapp numbers resolve phone number "<display number " output json
Fallback onboarding flow (direct API):
1. Create customer: POST /platform/v1/customers
2. Generate setup link: POST /platform/v1/customers/:id/setup links
3. Customer completes embedded signup
4. Use phone number id to send messages and configure webhooks
Detect connection:
Project webhook whatsapp.phone number.created (recommended)
Success redirect URL query params (use for frontend UX)
Recommended Kapso setup link defaults:
Notes:
kapso setup and kapso whatsapp numbers new use dedicated plus provisioning by default.
Keep phone number country isos , phone number area code , language , and redirect URLs as optional overrides.
Platform API base: /platform/v1
Meta proxy base: /meta/whatsapp/v24.0 (messaging, templates, media)
Use phone number id as the primary WhatsApp identifier
Receive events (webhooks)
Use webhooks to receive:
Project events (connection lifecycle, workflow events)
Phone number events (messages, conversations, delivery status)
Scope rules:
Project webhooks : only project level events (connection lifecycle, workflow events)
Phone number webhooks : only WhatsApp message + conversation events for that phone number id
WhatsApp message/conversation events ( whatsapp.message. , whatsapp.conversation. ) are phone number only
Create a webhook:
Project level: node scripts/create.js scope project url <https://... events <csv
Phone number: node scripts/create.js phone number id <id url <https://... events <csv
Common flags for create/update:
url <https://... webhook destination
events <csv json array event types (Kapso webhooks)
kind <kapso meta Kapso (event based) vs raw Meta forwarding
payload version <v1 v2 payload format ( v2 recommended)
buffer enabled <true false enable buffering for whatsapp.message.received
buffer window seconds <n 1 60 seconds
max buffer size <n 1 100
active <true false enable/disable
Test delivery:
Always verify signatures. See:
references/webhooks overview.md
references/webhooks reference.md
Send and read messages
Discover IDs first
Two Meta IDs are needed for different operations:
ID Used for How to discover
business account id (WABA) Template CRUD kapso whatsapp numbers resolve phone number "<display number " output json or node scripts/list platform phone numbers.mjs
phone number id Sending messages, media upload kapso whatsapp numbers resolve phone number "<display number " output json or node scripts/list platform phone numbers.mjs
Operate with the CLI first
Common commands:
SDK setup
Install:
Create client:
Send a text message
Via SDK:
Send a template message
1. Discover IDs: node scripts/list platform phone numbers.mjs
2. Draft template payload from assets/template utility order status update.json
3. Create: node scripts/create template.mjs business account id <WABA ID file <payload.json
4. Check status: node scripts/template status.mjs business account id <WABA ID name <name
5. Send: node scripts/send template.mjs phone number id <ID file <send payload.json
Send an interactive message
Interactive messages require an active 24 hour session window. For outbound notifications outside the window, use templates.
1. Discover phone number id
2. Pick payload from assets/send interactive .json
3. Send: node scripts/send interactive.mjs phone number id <ID file <payload.json
For a contact information request, use interactive.type: "request contact info" with action.name: "request contact info" . Include body , but omit header and footer .
Read inbox data
Preferred path:
CLI: kapso whatsapp messages ... , kapso whatsapp conversations ... , kapso whatsapp templates ...
Fallback path:
Proxy: GET /{phone number id}/messages , GET /{phone number id}/conversations
SDK: client.messages.query() , client.messages.get() , client.conversations.list() , client.conversations.get() , client.templates.get()
Embed the inbox
Use Platform API inbox embeds when the user wants to place Kapso's inbox inside their own app.
Create:
POST /platform/v1/inbox embeds
Envelope: inbox embed
Public scopes: project , customer , phone number
scope id is blank for project , a customer UUID for customer , and WhatsApp phone number id for phone number
language controls the embedded inbox UI language; supported values are en and es
Create returns token and embed url once. Store embed url ; list/get/update omit secrets.
Example:
Manage:
GET /platform/v1/inbox embeds
GET /platform/v1/inbox embeds/:id
PATCH /platform/v1/inbox embeds/:id
DELETE /platform/v1/inbox embeds/:id (revokes)
Template rules
Creation:
Use parameter format: "NAMED" with {{param name}} (preferred over positional)
Include examples when using variables in HEADER/BODY
Use language (not language code )
Don't interleave QUICK REPLY with URL/PHONE NUMBER buttons
URL button variables must be at the end of the URL and use positional {{1}}
For a REQUEST CONTACT INFO button, omit text ; WhatsApp supplies the label
Send time:
For NAMED templates, include parameter name in header/body params
URL buttons need a button component with sub type: "url" and index
Media headers use either id or link (never both)
WhatsApp Flows
Use Flows to build native WhatsApp forms. Read references/whatsapp flows spec.md before editing Flow JSON.
Create and publish a flow
1. Create flow: node scripts/create flow.js phone number id <id name <name
2. Update JSON: node scripts/update flow json.js flow id <id json file <path
3. Publish: node scripts/publish flow.js flow id <id
4. Test: node scripts/send test flow.js phone number id <id flow id <id to <phone
Attach a data endpoint (dynamic flows)
1. Set up encryption: node scripts/setup encryption.js flow id <id
2. Create endpoint: node scripts/set data endpoint.js flow id <id code file <path
3. Deploy: node scripts/deploy data endpoint.js flow id <id
4. Register: node scripts/register data endpoint.js flow id <id
Flow JSON rules
Static flows (no data endpoint):
Use version: "7.3"
routing model and data api version are optional
See assets/sample flow.json
Dynamic flows (with data endpoint):
Use version: "7.3" with data api version: "3.0"
routing model is required (defines valid screen transitions)
See assets/dynamic flow.json
Data endpoint rules
Handler signature:
Do not use export or module.exports
Completion uses screen: "SUCCESS" with extension message response.params
Do not include endpoint uri or data channel uri (Kapso injects these)
Troubleshooting
Search Logs before drilling into per resource endpoints: kapso logs search query "<wamid flow id request id or endpoint " period 7d source all limit 20 output json
Preview shows "flow token is missing" : flow is dynamic without a data endpoint. Attach one and refresh.
Encryption setup errors: enable encryption in Settings for the phone number/WABA.
OAuthException 139000 (Integrity): WABA must be verified in Meta security center.
Scripts
Webhooks
Script Purpose
list.js List webhooks
get.js Get webhook details
create.js Create a webhook
update.js Update a webhook
delete.js Delete a webhook
test.js Send a test event
Messaging and templates
Script Purpose Required ID
list platform phone numbers.mjs Discover business account id + phone number id —
list connected numbers.mjs List WABA phone numbers business account id
list templates.mjs List templates (with filters) business account id
template status.mjs Check single template status business account id
create template.mjs Create a template business account id
update template.mjs Update existing template business account id
send template.mjs Send template message phone number id
send interactive.mjs Send interactive message phone number id
upload media.mjs Upload media for send time headers phone number id
Flows
Script Purpose
list flows.js List all flows
create flow.js Create a new flow
get flow.js Get flow details
read flow json.js Read flow JSON
update flow json.js Update flow JSON (creates new version)
publish flow.js Publish a flow
get data endpoint.js Get data endpoint config
set data endpoint.js Create/update data endpoint code
deploy data endpoint.js Deploy data endpoint
register data endpoint.js Register data endpoint with Meta
get encryption status.js Check encryption status
setup encryption.js Set up flow encryption
send test flow.js Send a test flow message
delete flow.js Delete a flow
list flow responses.js List stored flow responses
list function logs.js List function logs
list function invocations.js List function invocations
OpenAPI
Script Purpose
openapi explore.mjs Explore OpenAPI (search/op/schema/where)
Examples:
Assets
File Description
template utility order status update.json UTILITY template with named params + URL button
send template order status update.json Send time payload for order status update
template utility named.json UTILITY template showing button ordering rules
template marketing media header.json MARKETING template with IMAGE header
template authentication otp.json AUTHENTICATION OTP template (COPY CODE)
send interactive buttons.json Interactive button message
send interactive list.json Interactive list message
send interactive cta url.json Interactive CTA URL message
send interactive location request.json Location request message
send interactive catalog message.json Catalog message
sample flow.json Static flow example (no endpoint)
dynamic flow.json Dynamic flow example (with endpoint)
webhooks example.json Webhook create/update payload example
References
[references/getting started.md](references/getting started.md) Platform onboarding
[references/platform api reference.md](references/platform api reference.md) Full endpoint reference
[references/setup links.md](references/setup links.md) Setup link configuration
[references/detecting whatsapp connection.md](references/detecting whatsapp connection.md) Connection detection methods
[references/webhooks overview.md](references/webhooks overview.md) Webhook types, signature verification, retries
[references/webhooks event types.md](references/webhooks event types.md) Available events
[references/webhooks reference.md](references/webhooks reference.md)