Skip to main content

Text

await client.messages.sendText({
  phoneNumberId: '123',
  to: '56961567267',
  body: 'Hola desde Kapso!',
  // Optional: disable URL previews
  previewUrl: false
});

Location

await client.messages.sendLocation({
  phoneNumberId: '123',
  to: '56961567267',
  location: {
    latitude: -33.4489,
    longitude: -70.6693,
    name: 'Santiago',
    address: 'CL'
  }
});

Contacts

await client.messages.sendContacts({
  phoneNumberId: '123',
  to: '56961567267',
  contacts: [
    {
      name: { formatted_name: 'Ada Lovelace' },
      org: { company: 'Analytical Engines' },
      phones: [{ phone: '+44123456789', type: 'WORK' }]
    }
  ]
});

Reaction

await client.messages.sendReaction({
  phoneNumberId: '123',
  to: '56961567267',
  reaction: { messageId: 'wamid.SOME_ID', emoji: '👍' }
});

Mark as read

await client.messages.markRead({
  phoneNumberId: '123',
  messageId: 'wamid.SOME_ID'
});

Message history

import { buildKapsoFields } from '@kapso/whatsapp-cloud-api';

// Query by time and direction
const page = await client.messages.query({
  phoneNumberId: '123',
  direction: 'inbound',
  since: '2025-01-01T00:00:00Z',
  limit: 50,
  fields: buildKapsoFields() // include Kapso extras (direction, flow_response, media_data, ...)
});

// List messages for a single conversation
const convMessages = await client.messages.listByConversation({
  phoneNumberId: '123',
  conversationId: 'conv-123',
  limit: 25,
  fields: buildKapsoFields(['media_url', 'flow_response']) // request only the fields you need
});

// Graph-style cursors are exposed under page.paging.cursors.before and page.paging.cursors.after
const nextCursor = page.paging.cursors.after;

> Tip: Include `media_url` to render images/documents directly when Kapso has attached them. See [Kapso Extensions](/docs/whatsapp/typescript-sdk/kapso-extensions) for the full list.
I