Create
Copy
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: 'customer_feedback',
category: 'UTILITY',
language: 'en_US',
components: [
{
type: 'BODY',
text: 'Hi {{customer_name}}, how was your experience with us?',
example: {
body_text_named_params: [
{ param_name: 'customer_name', example: 'Sarah' }
]
}
},
{
type: 'BUTTONS',
buttons: [
{
type: 'QUICK_REPLY',
text: 'Great!'
},
{
type: 'QUICK_REPLY',
text: 'Not good'
}
]
}
]
});
Send
Copy
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: 'customer_feedback',
language: { code: 'en_US' },
components: [
{
type: 'body',
parameters: [
{ type: 'text', text: 'Sarah' }
]
},
{
type: 'button',
sub_type: 'quick_reply',
index: '0',
parameters: [
{ type: 'payload', payload: 'positive_feedback' }
]
},
{
type: 'button',
sub_type: 'quick_reply',
index: '1',
parameters: [
{ type: 'payload', payload: 'negative_feedback' }
]
}
]
}
});

