Skip to content

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.

Browser
await client.conversation.sync();

Sync new conversations

Get any new group chat or DM conversations from the network.

Browser
await client.conversations.sync();

Sync all new welcomes, conversations, messages, and preferences

Sync all new welcomes, group chat and DM conversations, messages, and preference updates from the network.

By default, syncAll streams only conversations with a consent state of allowed or unknown.

We recommend streaming 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 all 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.

Browser
await client.conversations.syncAll(["allowed"]);