Introduction

Two nodes are available to execute control flow: If and Switch.

If Node

The If node is a simple conditional node that evaluates a condition and routes to the True or False branch. The If node accepts a single condition and routes to the True branch if the condition evaluates to true, otherwise it routes to the False branch.

For example, you may want to send one template if one data field represents a certain value, or another template if it does not:

Switch Node

For situations where a simple if true / false branch is insufficient, a switch node is available. The switch node accepts an arbitrary number of conditions and routes to the branch of the first condition to evaluate to true. If no conditions evaluate to true, the default branch is used.

Condition Sources

The If and Switch nodes have four different source options: data, profile, step ref and JS condition. These sources control whether to follow the True path or the False path by evaluating the sources.

Data

Compare a field within the data key within the automation context with a value. For example:

ConditionAutomation PayloadEvaluation
{ "recipient": "user123", "data": { "foo": "bar" } } True
{ "recipient": "user123", "data": { "throw": "scissors" } } False

Profile

Compare a field within the data key within the automation context with a value. For example:

ConditionAutomation PayloadEvaluation
{ "recipient": "user123", "profile": { "user_id": "user123", "first_name": "bryan" } } />True
{ "recipient": "user123", "profile": { "user_id": "user123", "properties": { "roles": [ "admin", "developer" ] } } } True

Step Ref

Step Ref is designed for you to check the current value of a Send node, mainly it’s status. See the screenshot below or view the tutorial. In order to use Step Ref, you must have a Send node and have the alias of the Send node defined in its configuration.

CLICKED | DELIVERED | ENQUEUED | FILTERED | OPENED | SENT | SIMULATED | UNDELIVERABLE | UNMAPPED | UNROUTABLE

Automation Control Flow

JS Condition

Sometimes the value checking is not open ended enough to evaluate a condition. Using the JS Condition you can:

  • manipulate the field value before comparing
  • check for key existence
  • Comparing date diffs as ISO strings
  • manipulate nested arrays and objects

We will evaluate the manipulation into a Javascript Boolean after the equation

ConditionAutomation PayloadEvaluation
{ "recipient": "user123", "data": { "names": [ { "name": "Alvin" }, { "name": "Simon" }, { "name": "Theo" } ] } } False

JS Condition Values

Within the Data, Profile and Step Ref Sources, you may also use JS String evaluation in the value field

ConditionAutomation PayloadEvaluation
{ "recipient": "user123", "data": { "ts": 1095869760000 } } True