How To Send Automations
A walkthrough on how to send Courier Automations through an ad-hoc API request, or template.
Automation Schema
It’s possible to define an Automation Schema in two ways:
- Ad-Hoc
- Automation template
Ad-Hoc Automations
Ad-hoc automations are one-time schema definitions that allow run context to be defined in the schema itself:
Automation Templates
AUTOMATION TEMPLATE VISUAL DESIGNER
An automation template is a re-usable, pre-defined list of automation steps created in the automation design studio.
Published templates are run or “invoked” using the Courier Automation API automations/:templateId/invoke endpoint.
By default, an automation template is a JSON schema definition of the following format:
Run context is passed in the API request body as a first-class object, and its values are referenced at the step level by using Accessor Types.
Structure
At runtime, you can pass a data and/or profile property into your template.
Invoking Automations
To trigger an automation run, there are two apis that can be called with your Courier API token.
automations/invoke
automations/{templateId}/invoke
Invoke An Ad-Hoc Automation Via API
POST - /automations/invoke
Invoke an ad hoc automation run, by providing a valid automation definition in the request body.
Structure
Invoke an Automation Template Via API
POST - /automations/{templateId}/invoke
Structure
Invoke a Template Via Segment
You can trigger an automation template via Segment event in the Automations Visual Designer.
INTEGRATE SEGMENT
You can follow Courier’s Segment integration guide here.
Once you have fished setting up Courier’s Segment Integration
- Open the Automation you wish to trigger via Segment event
- Click to open the Start step
- Select the segment event type(s) you want to trigger this event.
TRACK EVENT REQUIRES AN EXACT NAME MATCH
If you select a Segment Track event trigger to invoke your template, you must provide an event name that is the exact match to the event’s name in Segment.
Automation Examples
Sending a Digest Notification
Use automations to fetch data and render it in a group digest or send a digest with recipient-specific data to every member of a list.
Generic Digest
A generic digest is when every recipient in the list receives the same notification with the same data. To automate a generic digest, simply define a fetch-data step, followed by a send-list step. The data that is fetched, will be used to render a notification that is sent to each recipient.
This automation definition can be saved as an automation template and scheduled to be invoked on any recurring interval or once on a specific date.
Recipient Digest
A recipient digest is when every recipient in the list receives a unique notification with recipient-specific data.
To automate a recipient digest, define a send-list step with a data_source
property. Specific data will be fetched for each recipient and will be used to render a notification that is sent to each recipient. Note that the data_source.url
should accept a recipientId query string parameter.
This automation definition can be saved as a template and scheduled to be invoked on any recurring interval or once on a specific date.
Example Recipient Digest
As an example, you could use the recipient digest to send a weekly update to students of an online school platform.
By calling the data source, and getting the following payload:
You could send the following notification with each individual student’s progress:
Recipient digest notification template example.
Preview of the recipient digest template.
Batch Send to an Ad-Hoc List of Recipients
How to use Courier automations to batch send notifications to an ad hoc group of multiple recipients built at run time.
Automations allow you to use the send
action to deliver a message, or series of messages, to a list of users that you build dynamically at run time with a single Automation API call.
Data for each message can vary per step. This includes data, profile, and the template.
Here is an example: