Skip to main content

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: 'limited_time_offer',
  category: 'MARKETING',
  language: 'en_US',
  components: [
    {
      type: 'HEADER',
      format: 'IMAGE',
      example: {
        header_handle: ['4::aW1hZ2UvanBlZw==:ARa1ZDhwbLZM3EENeeg']
      }
    },
    {
      type: 'BODY',
      text: 'Exclusive offer for {{customer_name}}! Get {{discount_amount}} off with code {{discount_code}}.',
      example: {
        body_text_named_params: [
          { param_name: 'customer_name', example: 'Mark' },
          { param_name: 'discount_amount', example: '25%' },
          { param_name: 'discount_code', example: 'SUMMER25' }
        ]
      }
    }
  ]
});

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: 'limited_time_offer',
    language: { code: 'en_US' },
    components: [
      {
        type: 'header',
        parameters: [
          {
            type: 'image',
            image: {
              link: 'https://example.com/summer-sale.jpg'
            }
          }
        ]
      },
      {
        type: 'body',
        parameters: [
          { type: 'text', text: 'Mark' },
          { type: 'text', text: '25%' },
          { type: 'text', text: 'SUMMER25' }
        ]
      }
    ]
  }
});