Can Digest modify payload?
I have an email workflow which contains a digest.
This workflow is used to send emails of content changes in our app.
An example would be:
sometimes this can happen in a fast sucession and we want to pile the data into one message only, here is where my question comes in.
Could we use the digest to gather the multiple notifications data into one single notification?
Such as:
where the things in brackets are variables
6 Replies
You might use digest with the "John Doe" as
digest key
Then, you can use all the digested steps.
https://docs.novu.co/workflows/digest#1-digest-key
https://docs.novu.co/workflows/digest#writing-digest-templates
steps.events
ah I see, I'll give it a go with this info then! thank you very much
@Emil quick question, can I check two variables in the if clause?
such as:
follow-up question:
if digest returns only one element, does it set
step.digest
to true
anyway?
ah, I think I can achieve this with variants, but would love confirmation anyway@bjornaer, you just advanced to level 2!
@bjornaer To your first question:
"Can I check two variables in the if clause?" such as:Yes, in Handlebars templates used by Novu, you can check multiple conditions in an if clause by combining them with logical operators. The specific syntax you provided seems correct, as long as step.digest is a boolean and step.total_count is a number that you wish to compare against the value 2. (We might need to add it to our docs, do you mind navigating to place in the docs you were intuitively would went to to figure this out and open an issue? Usually it's in the bottom of the page with the text
Suggest edits
or Raise issue
)
if digest returns only one element, does it set step.digest to true anyway?
Yes, if a digest action is triggered and only one matching trigger activates the digest during its interval, step.digest will be set to true, and step.total_count will be 1.
Achieving this with variants:Yes, you can achieve conditional workflow steps using variants in Novu. Variants allow you to create different versions of a notification step based on specific conditions, such as subscriber data, payload, or webhook responses. When the notification is triggered, Novu evaluates the conditions and selects the appropriate variant to send. For example: You can have an email step in your workflow with multiple variants where each variant has conditions that determine which version of the email is sent to subscribers. During the notification sending phase, Novu's logic will select the appropriate variant based on the conditional information passed with the trigger event. Please ensure you correctly configure your variants and conditions to match the desired workflow behavior.
Just a small clarification - it is not the correct syntax for handlebars. We currently don't have the helpers to do an and/or operations.
thank you for the answers! I did in fact do two checks, one
if
and one equals
, this solved my case although it did make my custom code a bit more convoluted than it needed to be, nothing to worry about (but I would love support for and
ops in the handlebars!