Automation Steps
An automation is a graph: steps, and the connections between them. A contact enters at the trigger and follows the connections from step to step. The same format is returned by Get Automation and accepted by Create Automation and Update Automation, so you can read an automation, change it, and send it back.
{
"steps": [
{
"key": "trigger",
"type": "trigger",
"name": "Signed up",
"config": { "event": "custom_event", "event_name": "signed_up" }
},
{
"key": "wait_1_day",
"type": "delay",
"name": "Wait a day",
"config": { "duration": { "value": 1, "unit": "days" } }
}
],
"connections": [
{ "from": "trigger", "to": "wait_1_day", "type": "default" }
]
}
Steps
| Field | Type | Description |
|---|---|---|
key | string | Chosen by you. Letters, digits and underscores, not starting with a digit. Max 64 characters. Unique in the automation. The trigger's key is always trigger. |
type | string | One of the step types |
name | string | A label shown in the dashboard. Max 255 characters. |
config | object | The step's settings. Its fields depend on type. |
The key is the step's identity. Connections, runs and results refer to the step by it, so keep it the same when you update the automation.
Connections
| Field | Type | Description |
|---|---|---|
from | string | Key of the step it leaves |
to | string | Key of the step it enters |
type | string | Which way out of from it is |
| Step type | Connection types it can start |
|---|---|
condition | condition_met, condition_not_met |
wait_for_event | event_received, timeout |
| Any other step | default |
A step starts at most one connection of each type. A step with no outgoing connection, or a branch with none, ends the run there.
Rules
A graph that breaks one of these rules is refused with 422 automation_graph_invalid, and nothing is saved:
- There is exactly one
triggerstep, and its key istrigger. - Every connection goes from a step to another step of the automation, by a connection type its
fromstep can start. Nothing leads into the trigger. - Every step can be reached from the trigger.
- No step leads back to an earlier one: there are no loops.
- When a
conditionorwait_for_eventsplits the run in two, each branch either ends or runs into the one step where the two branches rejoin. A step inside a branch cannot be reached from outside that branch. - An automation holds at most 100 steps, and its steps and connections come to at most 256 KB.
An automation with no steps and no connections is allowed: it is an empty draft.
The error message names each problem as step_key.path: message, or automation: message when it concerns the whole graph.
Two branches that rejoin:
"connections": [
{ "from": "trigger", "to": "is_vip", "type": "default" },
{ "from": "is_vip", "to": "vip_email", "type": "condition_met" },
{ "from": "is_vip", "to": "standard_email", "type": "condition_not_met" },
{ "from": "vip_email", "to": "tag_contacted", "type": "default" },
{ "from": "standard_email", "to": "tag_contacted", "type": "default" }
]
Issues
A graph that follows the rules is saved, even when its steps are unfinished. What is left to do before the automation can be enabled is listed in its issues, and enabling it is refused with 422 automation_not_ready until the list is empty.
| Field | Type | Description |
|---|---|---|
step_key | string | null | The step concerned, or null for the automation as a whole |
path | string | Where in the step's config, e.g. template_id, or empty for the whole step |
message | string | Written for people and may be reworded. Branch on step_key and path, not on message. |
Issues cover:
- A
configfield that a step needs and lacks, or a value it does not accept. - A tag, list, template, campaign or segment that does not exist, a sending domain that is not verified, a WhatsApp template that is not approved, and an SMS step with no approved sender for its
purpose. - An automation with only a trigger. Add at least one step after it.
In config, a field set to null counts as left out.
Step types
type | What it does |
|---|---|
trigger | Starts a run |
send_email | Sends an email from a template |
send_sms | Sends an SMS |
send_whatsapp | Sends a WhatsApp template message |
send_push | Sends a push notification to the contact's devices |
show_in_app | Shows an in-app message |
add_tag, remove_tag | Tags or untags the contact |
add_to_list, remove_from_list | Adds the contact to a list, or removes them |
update_contact | Writes values to the contact |
delay | Holds the run for a while |
condition | Branches on whether the contact matches a filter |
wait_for_event | Holds the run until something happens, or a timeout passes |
In each table below, Needed to enable marks the fields the step must have before the automation can be enabled.
trigger
{
"key": "trigger",
"type": "trigger",
"name": "Cart abandoned",
"config": {
"event": "custom_event",
"event_name": "cart_abandoned",
"reentry": { "mode": "window", "window_hours": 24 }
}
}
| Field | Type | Needed to enable | Description |
|---|---|---|---|
event | string | Yes | What starts a run. See Trigger events. |
tag_id, list_id, form_id, segment_id, campaign_id, event_name | string | Depends on event | The event's target. Only the field the event takes is accepted. |
reentry | object | No | Whether a contact may enter again. See Re-entry. |
Trigger events
event | Starts a run when | Target |
|---|---|---|
contact_created | A contact is created | None |
contact_unsubscribed | A contact unsubscribes | None |
tag_added | The tag is added to a contact | tag_id, required |
list_added | A contact is added to the list | list_id, required |
form_submitted | The signup form is submitted | form_id, required |
entered_segment | A contact enters the segment | segment_id, required |
email_opened | A contact opens the email campaign | campaign_id, required |
email_clicked | A contact clicks the email campaign | campaign_id, required |
email_bounced | The email campaign bounces for a contact | campaign_id, required |
sms_clicked | A contact clicks the SMS campaign | campaign_id, required |
push_opened | A contact opens the push campaign | campaign_id; left out: any |
push_clicked | A contact clicks the push campaign | campaign_id; left out: any |
in_app_shown | The in-app message is shown to a contact | campaign_id; left out: any |
in_app_clicked | A contact clicks the in-app message | campaign_id; left out: any |
in_app_dismissed | A contact dismisses the in-app message | campaign_id; left out: any |
custom_event | You send the event for a contact | event_name, required |
event_name is the name of one of your events, exactly as defined, with no surrounding spaces.
Re-entry
reentry.mode decides whether a contact who has already entered may enter again:
mode | A contact enters |
|---|---|
always | Every time the trigger fires. This is the default when reentry is left out. |
once | Once, ever |
window | Again only once window_hours (1–8760) have passed since they last entered. window_hours is needed with this mode. |
not_while_active | Again only when they have no run of this automation still running or waiting |
send_email
| Field | Type | Needed to enable | Description |
|---|---|---|---|
template_id | string | Yes | The ID of one of your templates |
from_domain | string | Yes | A verified sending domain |
from_prefix | string | Yes | The part of the sender address before @. Letters, numbers and . _ % + -, max 64 characters. |
from_name | string | Yes | Sender name. Max 255 characters. |
reply_to | string | No | Reply-to address |
subject | string | No | Subject line, in place of the template's. Max 998 characters. May use merge tags. |
preheader | string | No | Preview text. Max 255 characters. May use merge tags. |
smart_sending | boolean | No | false sends even when the contact was messaged too recently under your Smart Sending settings. Left out, Smart Sending applies. |
send_sms
| Field | Type | Needed to enable | Description |
|---|---|---|---|
content | string | Yes | Message text. Max 1600 characters. May use merge tags. |
purpose | string | Yes | marketing or transactional. Decides which senders may carry it. |
sender_by_country | object | Where a country has several senders | Maps a country (as in List Senders, e.g. KSA) to the sender name to use there |
smart_sending | boolean | No | As in send_email |
The sender is chosen per contact from the senders approved for purpose in the contact's country. When a country has more than one, sender_by_country picks one; until it does, that country is an issue.
send_whatsapp
| Field | Type | Needed to enable | Description |
|---|---|---|---|
template_name | string | Yes | The name of an approved WhatsApp template |
language | string | Yes | The template's language code, e.g. en or ar |
parameters | object | No | Values for the template's placeholders, keyed by placeholder name. Up to 32. Values may use merge tags. See Filling in parameters. |
smart_sending | boolean | No | As in send_email |
send_push
Sends to every device of the contact. title, body and deep_link may use merge tags.
| Field | Type | Needed to enable | Description |
|---|---|---|---|
title | string | Yes | Max 200 characters |
body | string | Yes | Max 1000 characters |
image_url | string | No | Image shown with the notification |
icon_url | string | No | Notification icon |
deep_link | string | No | Where a tap leads |
android_channel_id | string | No | Android notification channel |
action_buttons | array | No | Up to 3 buttons, each { "action_id", "label", "deep_link" }. deep_link is optional. |
data | object | No | String key-value pairs passed to the app. Up to 32. |
ttl_seconds | integer | No | How long delivery may be retried, 60–2419200 (28 days) |
priority | string | No | high or normal |
smart_sending | boolean | No | As in send_email |
show_in_app
| Field | Type | Needed to enable | Description |
|---|---|---|---|
campaign_id | string | Yes | The ID of the in-app message to show |
expires_in_days | integer | No | How many days the message stays available to the contact, 1–90 |
add_tag and remove_tag
| Field | Type | Needed to enable | Description |
|---|---|---|---|
tag_id | string | Yes | The ID of one of your tags |
add_to_list and remove_from_list
| Field | Type | Needed to enable | Description |
|---|---|---|---|
list_id | string | Yes | The ID of one of your lists |
update_contact
Writes the values to the contact exactly as given. Merge tags are not rendered here. Set at least one field.
| Field | Type | Needed to enable | Description |
|---|---|---|---|
first_name | string | At least one field | Max 100 characters |
last_name | string | At least one field | Max 100 characters |
email | string | At least one field | An email address |
phone_number | string | At least one field | Digits only with the country code, optionally starting with + |
properties | object | At least one field | Up to 50 custom properties, by key. Values are strings (max 1000 characters), numbers or booleans. |
delay
| Field | Type | Needed to enable | Description |
|---|---|---|---|
duration | object | Yes | { "value": n, "unit": "minutes" | "hours" | "days" }. value is 1 or more. At most 365 days in all. |
condition
{
"key": "is_pro",
"type": "condition",
"name": "On the pro plan?",
"config": {
"filter": {
"type": "group",
"operator": "and",
"conditions": [
{ "type": "attribute", "field": "properties.plan", "operator": "equals", "value": "pro" }
]
}
}
}
| Field | Type | Needed to enable | Description |
|---|---|---|---|
filter | object | Yes | The rules the contact is checked against. See Filters. |
Checks the contact when the run reaches the step. The run leaves by condition_met when the contact matches filter, and by condition_not_met otherwise.
wait_for_event
{
"key": "wait_for_order",
"type": "wait_for_event",
"name": "Wait for an order",
"config": {
"filter": {
"type": "group",
"operator": "and",
"conditions": [{ "type": "event", "event_name": "order_placed" }]
},
"timeout": { "value": 4, "unit": "hours" }
}
}
| Field | Type | Needed to enable | Description |
|---|---|---|---|
filter | object | Yes | What to wait for. See Filters. |
timeout | object | Yes | How long to wait, in the same form as a delay's duration |
Holds the run until the contact's activity matches filter, then leaves by event_received. If timeout passes first, it leaves by timeout.
When no delay or earlier wait has held the run yet, activity since the trigger counts. After one has, only activity from the moment the run reaches this step counts.
Filters in conditions and waits
A condition or wait_for_event takes a filter written in the same grammar as a segment's. See Segment Filters for groups and rules.
A wait has a few limits a condition does not:
- It needs at least one
eventormessage_engagementrule: something that can happen. - An
eventrule in a wait takes nocount,time_windowornegate. - A
message_engagementrule in a wait needs achannel, and takes nonegate.
The message an earlier step sent
A message_engagement rule can point at a send step of the same automation. Set target_type to automation_step and target_id to that step's key. The rule then reads the message that step sent in this run:
{
"type": "message_engagement",
"target_type": "automation_step",
"target_id": "welcome_email",
"channel": "email",
"action": "opened"
}
The step must be a send step that always runs before the condition or wait, whichever branch the run took. If channel is set, it must be that step's channel. If the step was skipped, it sent nothing, and the rule matches no message.
Merge tags
Text that a send step sends may use merge tags: subject and preheader of an email, the content of an SMS, WhatsApp parameters, and the title, body and deep_link of a push. Email templates are rendered with the same values.
| Tag | Value |
|---|---|
{{firstName}}, {{lastName}}, {{email}}, {{phone}} | The contact's fields |
{{<property key>}} | A custom property of the contact |
{{event.<event name>.<field>}} | A field of the event that started the run, for a custom_event trigger |
{{firstName|there}} uses there when the contact has no first name. A tag with no value and no default is left empty.