Store values in variables

Keep a value in one place for the whole run, so several steps can read it and update it.

Tokens reach back to one specific step, and that covers most cases. Sometimes, though, a value has to travel further: a score several branches need, a counter that grows as a loop goes round, a setting the whole automation should share. That's exactly what automation variables are for.

Step 1: Declare the variables

  • Open the automation and click More > Manage variables.

The More menu with Manage variables
  • Each row is one variable: a Name, an optional Default value used before anything sets it, and a Description so the next person knows what it holds.

  • Click Add variable for another row, the bin icon to remove one, then Save.

The Automation variables dialog with one variable

Step 2: Set a variable in the flow

Add a Set variable step where the value becomes known, for example right after the trigger.

  • name: the variable to write to.

  • value: what to store. Insert a token to take it from an earlier step, for example the score that arrived with the webhook.

  • create_if_not_exists: Yes creates the variable if it was never declared. No fails instead, which is handy when you'd rather catch a typo than silently create a second variable.

  • description: what this value means.

The Set variable step with its name, value and options

Step 3: Read it further down

Anywhere below, reference the variable as {{var.<name>}}, for example {{var.lead_score}}. Two more steps come with it:

StepDoes
Set variableStores a value
Get variableReads a variable into the step's own output
Increment variableAdds to, or subtracts from, a number in one atomic step, which is what you want for counters inside a loop
The three variable steps in the step picker

When to use a variable instead of a token

UseWhen
A token, {{step.field}}The value comes from one step and is used just below it
A variable, {{var.name}}The value is set on one branch and read on another, counted up in a loop, or used in many places

💡 Variables belong to one automation and hold their value for the length of a run. See Pass data between steps for tokens and the Data Selector.