JamalJ
Convex Community15mo ago
29 replies
Jamal

How to handle the elapse of time for debounce logic in Convex?

I’m building the notification logic for direct messaging. My app is prelaunch, and I want to keep the notification logic simple for the MVP. For now, the logic should be based on data that's simple to gather, e.g. debounce time and read receipts. In the future, we may add more factors for the logic, e.g. user presence. And more notification types, e.g. native in-app notifications.

The key challenge I’m facing in Convex is managing time-based logic to debounce email notifications. Ideally, the app delays notifications for a short period in order to group multiple messages into a single email.

Below are my current potential approaches for debouncing. Which do you recommend?

A) Convex actions to handle server-side logic for delayed email sending. My concern is whether actions are the right tool for managing time-based workflows and how they interact with Convex’s persistence model.
B) Convex scheduled functions to periodically check for new notifications and batch-send them to the client.
C) Convex Workflow component to orchestrate long-running processes, ensuring that the debounce logic executes reliably over time. I'm considering defining a workflow that delays email sending to batch multiple messages.
D) Some other approach?
Was this page helpful?