The chat ID to read messages for (null for all chats)
Cursor object tracking the last processed message position
Number of messages to read in this batch
Optional
bounds: { sinceSeconds?: null | number; untilSeconds?: null | number }Optional time bounds for filtering messages
Optional
sinceSeconds?: null | numberStart timestamp in seconds (inclusive)
Optional
untilSeconds?: null | numberEnd timestamp in seconds (inclusive)
Promise resolving to an array of EvolutionMessageRow objects
const cursor: ChatCursor = { last_ts_seconds: null, last_message_id: null };
const bounds = { sinceSeconds: 1701111559, untilSeconds: 1701197959 };
const messages = await readBatchByChat(
"19175769740@s.whatsapp.net",
cursor,
100,
bounds
);
// Update cursor for next batch
if (messages.length > 0) {
const last = messages[messages.length - 1];
cursor.last_ts_seconds = last.messageTimestamp;
cursor.last_message_id = last.key?.id;
}
Reads a batch of WhatsApp Evolution messages for a specific chat using cursor-based pagination.
This function implements efficient pagination by using a cursor that tracks the last processed message position. It supports filtering by time bounds and ensures consistent ordering for reliable resumption.
The cursor-based approach allows for: