messaging-history.set event.
Handling the history payload
Listen formessaging-history.set and persist the data however you like. At minimum, store messages so you can return them from your getMessage callback.
syncType tells you which kind of sync delivered the payload (full vs. incremental), so you can decide whether to overwrite or merge.
Requesting full history
By default, Baileys connects with a Chrome browser profile, which limits how much history WhatsApp returns on the initial sync. To get full history, use the macOS desktop browser preset and setsyncFullHistory:
Full-history sync significantly increases startup time and memory on large accounts.
Disabling history sync
If you don’t want history at all, returnfalse from shouldSyncHistoryMessage:
On-demand history sync
Beyond the initial sync, you can ask the main device for older messages at any time usingsock.fetchMessageHistory: