Automations

Conditions and branching

Send files down different paths with Condition and Switch, and understand how branches skip and join.

A workflow can branch. A Condition step has a True and a False output, and a Switch step has one output per case plus Otherwise. Only the steps connected to the output that was chosen run; the others are skipped.

Condition

A Condition checks one or more rules and continues on True when they match:

  • Match decides whether all rules or any rule must match.
  • Each rule has a Value (usually from a step), an Operator, and for most operators a value to Compare with.
OperatorsFor
equals, doesn't equalAny value
contains, doesn't contain, starts with, ends withText and lists
matches the patternText, with a regular expression (at most 50 ms per match)
is greater than, is at least, is less than, is at mostNumbers and dates
exists, doesn't existWhether the value is there at all
is empty (null), isn't nullWhether it has a value
is empty, isn't emptyEmpty text or lists

Text comparisons ignore case unless you turn on Case-sensitive in the rule. A rule comparing a missing or null value doesn't match.

The step's result output is true or false, if a later step needs it.

Switch

A Switch compares one Value against a list of Cases in order, and continues on the first case it equals. Each case has an Output name (lowercase letters, digits and dashes, such as png or large) that becomes an output on the canvas. When nothing matches, the run continues on Otherwise.

Its case output holds the name of the output it took.

Skips and joins

A step runs once all the connections leading into it are settled and at least one of them was taken. If none were taken, the step is skipped, and so are the steps after it, unless another path still reaches them.

This makes joins simple. Connect both branches of a Condition to the same step, and it runs exactly once, after whichever branch ran:

File received → Condition (wide?) ─True──→ Resize ─┐
                                 └─False─────────────┴→ Save file

Here Save file runs whether or not Resize ran. But Resize's output only exists on the True branch, so Save file can't simply read Resize's content: on the False branch that value is missing. See Values and templates.

When both branches need to hand content to the same step, give each branch its own Save file instead of joining them. In an intake workflow, two Save file steps that both save the upload are allowed as long as they're on different branches of the same Condition or Switch.

Order of steps

A run works on one step at a time. When several steps are ready, it picks them in a fixed order (by how far they are from the trigger, then by step id), so the same workflow always runs its steps in the same order, whatever order you added them in.

Handling failures on a branch

Under a step's Advanced settings, If this step fails can be set to Take the error path. The step gets an Error output; connect steps to it to handle the failure, for example to tag the file needs-review. Those steps can read steps.<id>.error.code and steps.<id>.error.message. A run that took an error path ends as Completed with errors.

Stopping early

The Stop step (in Flow) ends the run where it is and skips everything after it. Give it a Reason to see in the run's history.

In an intake workflow, stopping before a Save file step has saved the upload means the upload is never saved. The run fails with primary_not_saved and the workflow's failure policy applies, which by default sends the upload to quarantine.