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: 'auth_otp_copy_code',
category: 'AUTHENTICATION',
language: 'en_US',
components: [
{
type: 'BODY',
add_security_recommendation: true
},
{
type: 'FOOTER',
code_expiration_minutes: 10
},
{
type: 'BUTTONS',
buttons: [
{
type: 'OTP',
otp_type: 'COPY_CODE',
text: 'Copy Code'
}
]
}
]
});
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: 'auth_otp_copy_code',
language: { code: 'en_US' },
components: [
{
type: 'body',
parameters: [
{ type: 'text', text: '123456' }
]
},
{
type: 'button',
sub_type: 'otp',
index: '0',
parameters: [
{ type: 'text', text: '123456' }
]
}
]
}
});

