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: 'order_confirmation',
  category: 'UTILITY',
  language: 'en_US',
  components: [
    {
      type: 'BODY',
      text: 'Hi {{customer_name}}, your order {{order_number}} has been confirmed!',
      example: {
        body_text_named_params: [
          { param_name: 'customer_name', example: 'Jessica' },
          { param_name: 'order_number', example: 'SKBUP2-4CPIG9' }
        ]
      }
    }
  ]
});
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: 'order_confirmation',
    language: { code: 'en_US' },
    components: [
      {
        type: 'body',
        parameters: [
          { type: 'text', text: 'Jessica' },
          { type: 'text', text: 'SKBUP2-4CPIG9' }
        ]
      }
    ]
  }
});

