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: 'seasonal_promotion',
category: 'MARKETING',
language: 'en_US',
components: [
{
type: 'HEADER',
format: 'TEXT',
text: '{{sale_name}} is here!',
example: {
header_text_named_params: [
{ param_name: 'sale_name', example: 'Black Friday Sale' }
]
}
},
{
type: 'BODY',
text: 'Save big with code {{discount_code}}. Offer ends {{end_date}}.',
example: {
body_text_named_params: [
{ param_name: 'discount_code', example: 'BF2024' },
{ param_name: 'end_date', example: 'November 30th' }
]
}
},
{
type: 'FOOTER',
text: 'Terms and conditions apply'
}
]
});
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: 'seasonal_promotion',
language: { code: 'en_US' },
components: [
{
type: 'header',
parameters: [
{ type: 'text', text: 'Black Friday Sale' }
]
},
{
type: 'body',
parameters: [
{ type: 'text', text: 'BF2024' },
{ type: 'text', text: 'November 30th' }
]
}
]
}
});

