Skip to main content

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​

FieldTypeDescription
keystringChosen 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.
typestringOne of the step types
namestringA label shown in the dashboard. Max 255 characters.
configobjectThe 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​

FieldTypeDescription
fromstringKey of the step it leaves
tostringKey of the step it enters
typestringWhich way out of from it is
Step typeConnection types it can start
conditioncondition_met, condition_not_met
wait_for_eventevent_received, timeout
Any other stepdefault

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 trigger step, and its key is trigger.
  • Every connection goes from a step to another step of the automation, by a connection type its from step 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 condition or wait_for_event splits 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.

FieldTypeDescription
step_keystring | nullThe step concerned, or null for the automation as a whole
pathstringWhere in the step's config, e.g. template_id, or empty for the whole step
messagestringWritten for people and may be reworded. Branch on step_key and path, not on message.

Issues cover:

  • A config field 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​

typeWhat it does
triggerStarts a run
send_emailSends an email from a template
send_smsSends an SMS
send_whatsappSends a WhatsApp template message
send_pushSends a push notification to the contact's devices
show_in_appShows an in-app message
add_tag, remove_tagTags or untags the contact
add_to_list, remove_from_listAdds the contact to a list, or removes them
update_contactWrites values to the contact
delayHolds the run for a while
conditionBranches on whether the contact matches a filter
wait_for_eventHolds 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 }
}
}
FieldTypeNeeded to enableDescription
eventstringYesWhat starts a run. See Trigger events.
tag_id, list_id, form_id, segment_id, campaign_id, event_namestringDepends on eventThe event's target. Only the field the event takes is accepted.
reentryobjectNoWhether a contact may enter again. See Re-entry.

Trigger events​

eventStarts a run whenTarget
contact_createdA contact is createdNone
contact_unsubscribedA contact unsubscribesNone
tag_addedThe tag is added to a contacttag_id, required
list_addedA contact is added to the listlist_id, required
form_submittedThe signup form is submittedform_id, required
entered_segmentA contact enters the segmentsegment_id, required
email_openedA contact opens the email campaigncampaign_id, required
email_clickedA contact clicks the email campaigncampaign_id, required
email_bouncedThe email campaign bounces for a contactcampaign_id, required
sms_clickedA contact clicks the SMS campaigncampaign_id, required
push_openedA contact opens the push campaigncampaign_id; left out: any
push_clickedA contact clicks the push campaigncampaign_id; left out: any
in_app_shownThe in-app message is shown to a contactcampaign_id; left out: any
in_app_clickedA contact clicks the in-app messagecampaign_id; left out: any
in_app_dismissedA contact dismisses the in-app messagecampaign_id; left out: any
custom_eventYou send the event for a contactevent_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:

modeA contact enters
alwaysEvery time the trigger fires. This is the default when reentry is left out.
onceOnce, ever
windowAgain only once window_hours (1–8760) have passed since they last entered. window_hours is needed with this mode.
not_while_activeAgain only when they have no run of this automation still running or waiting

send_email​

FieldTypeNeeded to enableDescription
template_idstringYesThe ID of one of your templates
from_domainstringYesA verified sending domain
from_prefixstringYesThe part of the sender address before @. Letters, numbers and . _ % + -, max 64 characters.
from_namestringYesSender name. Max 255 characters.
reply_tostringNoReply-to address
subjectstringNoSubject line, in place of the template's. Max 998 characters. May use merge tags.
preheaderstringNoPreview text. Max 255 characters. May use merge tags.
smart_sendingbooleanNofalse sends even when the contact was messaged too recently under your Smart Sending settings. Left out, Smart Sending applies.

send_sms​

FieldTypeNeeded to enableDescription
contentstringYesMessage text. Max 1600 characters. May use merge tags.
purposestringYesmarketing or transactional. Decides which senders may carry it.
sender_by_countryobjectWhere a country has several sendersMaps a country (as in List Senders, e.g. KSA) to the sender name to use there
smart_sendingbooleanNoAs 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​

FieldTypeNeeded to enableDescription
template_namestringYesThe name of an approved WhatsApp template
languagestringYesThe template's language code, e.g. en or ar
parametersobjectNoValues for the template's placeholders, keyed by placeholder name. Up to 32. Values may use merge tags. See Filling in parameters.
smart_sendingbooleanNoAs in send_email

send_push​

Sends to every device of the contact. title, body and deep_link may use merge tags.

FieldTypeNeeded to enableDescription
titlestringYesMax 200 characters
bodystringYesMax 1000 characters
image_urlstringNoImage shown with the notification
icon_urlstringNoNotification icon
deep_linkstringNoWhere a tap leads
android_channel_idstringNoAndroid notification channel
action_buttonsarrayNoUp to 3 buttons, each { "action_id", "label", "deep_link" }. deep_link is optional.
dataobjectNoString key-value pairs passed to the app. Up to 32.
ttl_secondsintegerNoHow long delivery may be retried, 60–2419200 (28 days)
prioritystringNohigh or normal
smart_sendingbooleanNoAs in send_email

show_in_app​

FieldTypeNeeded to enableDescription
campaign_idstringYesThe ID of the in-app message to show
expires_in_daysintegerNoHow many days the message stays available to the contact, 1–90

add_tag and remove_tag​

FieldTypeNeeded to enableDescription
tag_idstringYesThe ID of one of your tags

add_to_list and remove_from_list​

FieldTypeNeeded to enableDescription
list_idstringYesThe 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.

FieldTypeNeeded to enableDescription
first_namestringAt least one fieldMax 100 characters
last_namestringAt least one fieldMax 100 characters
emailstringAt least one fieldAn email address
phone_numberstringAt least one fieldDigits only with the country code, optionally starting with +
propertiesobjectAt least one fieldUp to 50 custom properties, by key. Values are strings (max 1000 characters), numbers or booleans.

delay​

FieldTypeNeeded to enableDescription
durationobjectYes{ "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" }
]
}
}
}
FieldTypeNeeded to enableDescription
filterobjectYesThe 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" }
}
}
FieldTypeNeeded to enableDescription
filterobjectYesWhat to wait for. See Filters.
timeoutobjectYesHow 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 event or message_engagement rule: something that can happen.
  • An event rule in a wait takes no count, time_window or negate.
  • A message_engagement rule in a wait needs a channel, and takes no negate.

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.

TagValue
{{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.