The Digest node aggregates multiple triggers into a single, summarized notification sent at a recurring schedule. Some common usecases include sending recommendations or top stories like you get for Linkedin or Quora, or to send a weekly / daily summary of activities in a company workspace or SaaS application.

You can configure Digest nodes to send notifications on a fixed schedule to all users or a dynamic schedule based on user preferences.

Digest can be configured to be timezone-aware, ensuring that final notifications are sent in user’s preferred timezone and all users receive the digest at a reasonable hour.

How Digest works?

1

Opens batch window

When a workflow reaches the Digest node, it opens a batch until the next digest schedule is triggered. Unlike regular batching, the Digest node operates on a fixed schedule rather than being relative to when the first event is received. Consequently, the next steps following the Digest node will be executed at the fixed schedule, regardless of when triggers are received.

2

Accumulates trigger until the next digest schedule

During the batch period, all events for the same recipient with the same workflow slug are accumulated. A unique batch is created for each recipient.

3

Moves to next workflow step

When the digest schedule is reached, a single notification is sent for each batch. You can configure the number of events retained in the batch using the retain items setting. The digest output structure is similar to the batch output and templates can be edited in the same format as you do for batched alerts. Refer to Using Batch Variables in Templates for more details.

If no triggers are received within a given schedule or if the number of events is below the minimum trigger count, the workflow will exit without executing subsequent steps.

Example Usecase

A workflow sends a summary of task status changes daily at 7:00 PM for a workflow management tool.In this case, the workflow will batch all triggers for 11 hours (until July 30, 7:00 PM Europe/London) and the email will be sent at the same time as soon as batch is closed.

  • Trigger: When task status is changed (First task status change is received at Jul 30, 7:00 am UTC)
  • Digest Schedule: Daily at 7:00 pm (in recipient’s timezone)
  • Recipient’s Timezone: Europe/London (UTC+1).

In this case, the workflow will batch all triggers for 11 hours (until July 30, 7:00 PM Europe/London) and the email will be sent at the same time as soon as batch is closed.

Configuring Digest schedule

It is the recurring schedule when an open digest should be closed. This schedule might differ from the time notifications are actually sent. For example, if you want to send a daily digest summarizing activities from the previous day at 9:00 AM, you would set the Digest schedule to close daily at midnight and follow it with Time Window or Delay node to send the notification at 9:00 AM.

Advanced Settings

Using Digest (Batch) variables in templates

Batch output variable has 2 type of variables:

  1. $batched_eventsarray : All the event properties corresponding to a batched event is appended to this array and can be used in the template in the array format. The number of event properties returned here is limited by retain batch events.
  2. $batched_event_count: This count represents the number of events in a batch and is utilized to render the batch count in a template. For instance, you might send a message like,Joe left 5 comments in the last 1 hourwhere 5 corresponds to $batched_event_count.

📘 Please note that Retain items setting doesn’t impact the count, it just limits the number of trigger data returned in $batched_events array.

Let’s understand the batch variable structure with an example of task comments with below notification content.

3 comments are added on your task in last 1 hour.

- Steve: Hey, added the test cases added for PRD-12

- Olivia: Hey, done with the testing. Check the bugs

- Joe: 3 bugs are resolved, 4 are still pending

Here is a list of events triggered in the batched window:

//Event 1

const event_name = "new_comment" 

const properties = {													
  "name": "Steve",
  "card_id": "SS-12",
  "comment": "Hey, added the test cases added for PRD-12"
}  

const event = new Event(distinct_id, event_name, properties)

//Event 2

const event_name = "new_comment" 

const properties = {													
  "name": "Olivia",
  "card_id": "SS-12",
  "comment": "Hey, done with the testing. Check the bugs"
}  

const event = new Event(distinct_id, event_name, properties)

//Event 3

const event_name = "new_comment" 

const properties = {													
  "name": "Joe",
  "card_id": "SS-12",
  "comment": "3 bugs are resolved, 4 are still pending"
}  

const event = new Event(distinct_id, event_name, properties)

Output variable of the batch will have $batched_events_count and $batched_events array of all properties passed in the event payload as shown below:

{
  "$batched_events": [
    {
      "name": "Steve",
      "card_id": "SS-12",
      "comment": "Hey, added the test cases added for PRD-12"
    },
    {
      "name": "Olivia",
      "card_id": "SS-12",
      "comment": "Hey, done with the testing. Check the bugs"
    },
    {
      "name": "Joe",
      "card_id": "SS-12",
      "comment": "3 bugs are resolved, 4 are still pending"
    }
  ],
  "$batched_events_count": 3
}

This is how you’ll add the variable in your template to render the desired notification content.

{{$batched_events_count}} comments are added on your task in last 1 hour.

{{#each $batched_events}}
- {{name}}: {{comment}}

{{/each}}

You can also test this behaviour via Enable batching option in Mock data button on template details page. Once enabled, you’ll start getting $batched_events variable in auto suggestion on typing {{ in template editor. The variables in mock data will be treated as event properties and Event Count will imitate the number of times this event will be triggered in the batch.

Transforming Digest Variable Output

There can be cases where you need to split the digest output variables into multiple arrays based on keys in your input data. For example, to send a message like You have got 5 comments and 3 likes on your post today where post and likes are interaction_type in your input payload. You can use data transform node and generate relevant variables using JSONNET editor to handle this usecase.

Let’s take below example. There are 3 post interactions, 2 comments and 1 like and this is your workflow trigger.

//Event 1

const event_name = "new_post_interaction" 

const properties = {													
  "name": "Steve",
  "post_id": "PS-12",
  "interaction_type":"comment",
  "comment": "Well written! looking for more such posts"
}  

const event = new Event(distinct_id, event_name, properties)

//Event 2

const event_name = "new_post_interaction" 

const properties = {													
  "name": "Olivia",
  "card_id": "PS-12",
  "interaction_type":"like"
}  

const event = new Event(distinct_id, event_name, properties)

//Event 3

const event_name = "new_post_interaction" 

const properties = {													
  "name": "Joe",
  "post_id": "PS-12",
  "interaction_type":"comment",
  "comment": "Every leader should read this"
}  

const event = new Event(distinct_id, event_name, properties)

Without transformation, digest output will look like this:

{
  "$batched_events":[
    {												
  "name": "Steve",
  "post_id": "PS-12",
  "interaction_type":"comment",
  "comment": "Well written! looking for more such posts"
    },
   {													
  "name": "Olivia",
  "card_id": "PS-12",
  "interaction_type":"like"
} ,
 {													
  "name": "Joe",
  "post_id": "PS-12",
  "interaction_type":"comment",
  "comment": "Every leader should read this"
}   
  ],
 "$batched_events_count":3
}

We’ll add 3 variables in data transform node

  • comment_count: to get the count of all interactions whereinteraction_type = comment
  • like_count: to get the count of all interactions whereinteraction_type = like
  • all_comments: to fetch all array objects whereinteraction type = comment
//comment_count
std.length([x for x in data["$batched_events"] if x.interaction_type == "comment"])

//like_count
std.length([x for x in data["$batched_events"] if x.interaction_type == "like"])

//all_comments
[x.comment for x in data["$batched_events"] if x.interaction_type == "comment"]

After data transform node, output variables will contain 3 additional keys generated above. You can use these variables in your template to send the desired message as You have got {{comment_count}} comments and {{like_count}} likes on your post today.


{
  "comment_count":"2",
  "like_count":"1",
  "all_comments":["Well written! looking for more such posts","Every leader should read this"],
  "$batched_events":[
    {												
  "name": "Steve",
  "post_id": "PS-12",
  "interaction_type":"comment",
  "comment": "Well written! looking for more such posts"
    },
   {													
  "name": "Olivia",
  "card_id": "PS-12",
  "interaction_type":"like"
} ,
 {													
  "name": "Joe",
  "post_id": "PS-12",
  "interaction_type":"comment",
  "comment": "Every leader should read this"
}   
  ],
 "$batched_events_count":3
}

Some Common Notification Usecases

Frequently asked questions