Create
import { WhatsAppClient } from '@kapso/whatsapp-cloud-api';
const client = new WhatsAppClient({
baseUrl: 'https://api.kapso.ai/meta/whatsapp',
kapsoApiKey: process.env.KAPSO_API_KEY!
});
await client.templates.create({
businessAccountId: '123456789',
name: 'appointment_booking',
category: 'UTILITY',
language: 'en_US',
parameterFormat: 'NAMED',
components: [
{
type: 'BODY',
text: 'Hi {{customer_name}}, book your appointment using the button below.',
example: {
body_text_named_params: [
{ param_name: 'customer_name', example: 'Michael' }
]
}
},
{
type: 'BUTTONS',
buttons: [
{
type: 'FLOW',
text: 'Book Now',
flow_id: '123456789012345',
flow_action: 'navigate'
}
]
}
]
});
curl -X POST 'https://api.kapso.ai/meta/whatsapp/v24.0/123456789/message_templates' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"name": "appointment_booking",
"category": "UTILITY",
"language": "en_US",
"parameter_format": "NAMED",
"components": [
{
"type": "BODY",
"text": "Hi {{customer_name}}, book your appointment using the button below.",
"example": {
"body_text_named_params": [
{ "param_name": "customer_name", "example": "Michael" }
]
}
},
{
"type": "BUTTONS",
"buttons": [
{
"type": "FLOW",
"text": "Book Now",
"flow_id": "123456789012345",
"flow_action": "navigate"
}
]
}
]
}'
Send
import { WhatsAppClient } from '@kapso/whatsapp-cloud-api';
const client = new WhatsAppClient({
baseUrl: 'https://api.kapso.ai/meta/whatsapp',
kapsoApiKey: process.env.KAPSO_API_KEY!
});
await client.messages.sendTemplate({
phoneNumberId: '647015955153740',
to: '15551234567',
template: {
name: 'appointment_booking',
language: { code: 'en_US' },
components: [
{
type: 'body',
parameters: [
{ type: 'text', parameterName: 'customer_name', text: 'Michael' }
]
},
{
type: 'button',
sub_type: 'flow',
index: '0',
parameters: [
{
type: 'action',
action: {
flow_token: 'user_session_abc123',
flow_action_data: {
customer_id: 'cust_12345',
preferred_date: '2024-02-15'
}
}
}
]
}
]
}
});
curl -X POST 'https://api.kapso.ai/meta/whatsapp/v24.0/647015955153740/messages' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"messaging_product": "whatsapp",
"to": "15551234567",
"type": "template",
"template": {
"name": "appointment_booking",
"language": {
"code": "en_US"
},
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "parameter_name": "customer_name", "text": "Michael" }
]
},
{
"type": "button",
"sub_type": "flow",
"index": "0",
"parameters": [
{
"type": "action",
"action": {
"flow_token": "user_session_abc123",
"flow_action_data": {
"customer_id": "cust_12345",
"preferred_date": "2024-02-15"
}
}
}
]
}
]
}
}'

