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.