Sending Digests With Automations

Courier’s digest workflow consists of the following mechanisms:

  • Preference topics to set a configured interval
  • Message templates that reference the digested event data sent to a recipient
  • Automations to ingest the incoming digest data, and to trigger the digest.

Creating a Digest in Preferences

To create your first digest, you will need to create a new subscription topic with at least one schedule. Head over to the preferences editor and create a new subscription topic.

Notification templates don’t need to be mapped to a digest subscription topic since they are triggered through an automation.

Digest Settings

Once your digest subscription topic is created, you need to enable the digests toggle to allow scheduling, configure categories, link notifications, and access more advanced settings.

Schedules

This section is for defining the schedule the digest will be released. At least one is required, but multiple schedules are accepted to give your users a preference of their desired schedule. They will have the choice to edit this through the preferences hosted page.

We can add one schedule for now. This will be our default schedule.

Digest Schedule

Categories

Every digest should have a category. There will always be a default category key, in this case it’s digest. This is how the data will be released to the automation under a specific category key.

For 10 highest or 10 lowest retain items, a sort-key will be required so Courier can sort which items it needs to sort.

Digest Category Key

With the current retain setting for sorting the 10 highest likes, Courier will digest the 10 highest likes items coming in from event payloads.

Sample payload:

{
    "channel": "server",
    "email": "rodrigo@courier.com",
    "event": "tweet",
    "likes": 20, // Courier will digest the highest 10 likes out of n events
    "messageId": "segment-test-message-asc5f",
    "projectId": "dvH4TNFwoeMr729ExtJ8aQ",
    "properties": {
      "property1": 1,
      "property2": "test",
      "property3": true
    },
    "replay": true,
    "timestamp": "2025-01-10T16:57:29.568Z",
    "tweet": "Hello World",
    "type": "track",
    "userId": "rod"
  }

Digesting With Automations

The next step in the digest process is to link automations to the subscription topic that holds the digest settings. We will need to use 2 separate automations:

  • One that adds the events to the digest
  • The digest trigger that adds the digested events to a notification

Adding to Digest

The first automation will add incoming events from the specified trigger into the digest. The digest node should be mapped to the preference topic that holds your digest settings.

Add to Digest Automation

Digest Trigger

The second automation will trigger once the retained items are met. The send step will consume the incoming data and should be configured to parse the data accordingly. Make sure all your templates are published before sending any events.

Trigger Digest Automation

Digested Events

Courier’s Automation Logs will give you insight on digested events triggered by automations. Each event that comes in will be marked as add-to-digest.

Digest Log

Once the retained strategy is met, the automation logs will show a triggered event with (in our case) the top ten likes gathered from the events.

Digest Trigger Invoked

Subsequently, the message logs will contain the digested data and pass it to the notification template.

Digest Context Passed to Template