How to batch product notifications via code
Leverage Novu’s Digest Engine to batch product notifications
Introduction
Learn how to use Novu’s Digest engine to batch notifications. In this guide, you’ll learn how to aggregate multiple messages and send them off as one notification. Follow these steps:
Getting started
Integrating Novu’s code-first workflow with React.Email for your Next.js application can be done in three steps
- Create a fully-featured Novu NextJS app with the command below:
- Once this installation is complete, simply
cd
into the directory and start your app using thenpm run dev
command.
Now, we’re all set to send digested notifications but before we do, let’s look at what it is and how it works:
Digest engine and how it works
Novu’s Digest Engine is designed to consolidate multiple trigger events into a single cohesive message before delivering it to the subscriber. This functionality is essential for managing notification overload and ensuring that users receive meaningful, aggregated updates rather than being bombarded with numerous individual notifications. Here’s how it works:
- Event Accumulation: The digest engine collects multiple trigger events based on a unique
subscriberId
to be delivered as one message. - Batching Events: The engine batches these events within a specified time interval. This interval can be configured in units of seconds, minutes, hours, days, weeks, or months.
- Delivery: After the accumulation period, the batched events are sent out as a single notification. This consolidated message reduces the frequency of notifications and provides the user with a summary of all relevant events.
How to digest in a code-first workflow:
- Write a workflow and add a digest node to it:
💡 In the digest node above, you can change the digest duration by setting a value to the key amount
and changing the value of unit
to seconds, minutes, hours, days, weeks, or months
- Here’s a simple client-side app with a handler function attached to the
submit
event:
- And the corresponding route that it hits once the event fires:
That’s it!
That’s how simple it is to use Novu’s Digest Engine. Digesting notifications enhances the user experience by providing comprehensive summaries, making it easier for users to stay informed about important updates in a concise manner, without straining users with too many notifications. We have got a thorough guide on digesting notifications in our docs that you can check out as well.
Was this page helpful?