Sync conversations and messages
🎥 walkthrough: Syncing
This video provides a walkthrough of key concepts required to implement syncing correctly.
Sync a specific conversation
Get all new messages and group updates (name, description, etc.) for a specific conversation from the network.
await client.conversation.sync();Sync new conversations
Get any new group chat or DM conversations from the network.
await client.conversations.sync();Sync new welcomes, conversations with unread messages, and preferences
Use syncAll to sync the following from the network:
- New welcomes
- Group chat and DM conversations with a consent state of allowed or unknown that have unread messages
- Preference updates
We recommend syncing messages for allowed conversations only. This ensures that spammy conversations with a consent state of unknown don't take up networking resources. This also ensures that unwanted spam messages aren't stored in the user's local database.
To sync conversations regardless of consent state, pass [ALLOWED, UNKNOWN, DENIED].
To sync preferences only, you can call preferences.sync. Note that preferences.sync will also sync welcomes to ensure that you have all potential new installations before syncing.
The method returns a summary that includes the total number of conversations and the number of conversations that were actually synced.
await client.conversations.syncAll(['allowed']);
