Skip to content

Send a WhatsApp message

Your organization needs a connected WhatsApp number (console in AirFone, Channels). Test mode uses a simulated number, so you can try this before connecting one.

If the customer wrote to you in the last 24 hours, send free text:

Terminal window
curl https://api.airfone.app/v1/messages \
-H "Authorization: Bearer af_sk_test_..." \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"channel": "whatsapp", "to": "+9779800000001", "text": "Your order 1042 is on its way."}'

WhatsApp requires an approved template:

{
"channel": "whatsapp",
"to": "+9779800000001",
"template": { "name": "order_shipped", "language": "ne", "parameters": ["1042"] }
}

If you send free text outside the window, the API answers 422 with code whatsapp_window_closed.

Replies go to the assistant, which answers as it does for any WhatsApp chat. Subscribe to message.received to see them, and to conversation.needs_person to know when the assistant hands over.

For SMS, set "channel": "sms". Templates do not apply.