Automated flow session variables allow you to store information that remains available for the duration of a flow session.
You can use them to personalise messages, perform checks within automated flow nodes, or store values calculated during the session. Variables can generally be used in verification nodes or in the content of a message.
Why use variables
A session variable is a temporary container for information that exists only whilst a specific automated flow session is running. They are useful when information needs to be reused several times during the session. For example, you can:
- store the initial value of a contact field;
- calculate a date or an amount once and reuse it in subsequent nodes;
- personalise the content of communications;
- avoid repeating the same expression in multiple places within the flow.
Define the variable
Open the automated flow home page and click Edit in the Settings card.
In the Variables section, you can view the available variables and add new ones.
When you create a variable, choose the data type it will contain:
- integer: example, loyalty program points at the beginning of the flow
- string: for text values;
- date and time: example, the date of issue of a voucher or the expiration date of a subscription;
- Yes/No: for example, the contact is subscribed to a service;
- list of values;
- decimal number: for example, the amount of the last donation made.
The name is displayed in the magnews interface, whilst the ID identifies the variable in expressions and placeholders – therefore, it must not contain any spaces or special characters.
Set a default value
You can assign a default value to a variable, which will be used automatically at the start of each new automated flow session.
If the variable is already assigned a value in the flow input node, the default value will not be used.
You can set the following as the default value:
- a function, for example
fn.today(); - a contact field, for example
contact.values.FIELDNAME; - a constant value. For example:
-
1for numeric variables -
'promo'for text types or to indicate the default option for list of values variables '1992-04-18'for dates or'1992-04-18 10:30:00'for datetimes.
-
The default value is useful when you want to initialise a variable without adding an Update variable node at the start of the automated flow.
Assign a value
You can change the value of a variable whilst the automated flow is running using the Update variable node. The new value replaces the default value or the value previously assigned.
The value is often assigned at the beginning of the session, in order to preserve the initial value of a field, or to calculate a value that will be used later throughout the automated flow session.
Example...
Let’s declare a variable that contains the promotion end date, setting it to 30 days after the contact’s birthday. You can then use this variable, with the calculated date, both in a condition check node and in the body of a message.
Enter the expression to calculate the value of the variable:
- to use the value of a contact field: contact.values.NAME;
- to use the value of a automated flow variable: workflow.values.NOMEVAR;
- to assign a value to a number, use a period as the decimal separator (not a comma);
- to assign a value to a True/False type, only the following are accepted: true/false, yes/no;
- for single or multiple choice types, if you specify a value that does not exist, the variable will not be evaluated;
- to assign a text value to a variable, you must enclose it in quotation marks: ‘color’.
Example expression: to add 1 to the value of a numeric variable, use workflow.values.VARIABLENAME + 1.
Check which functions you can use to manipulate numbers, dates, or text strings. In the example, fn.today() expresses today's date.
Use the variable
Once a value has been assigned to the variable, it can be used at various points in the automated flow.
Use the variable value in your automated flow messages by adding the placeholder with the syntax [workflow:variableID] or use the icon to insert a placeholder and select “Workflow variables” from the first dropdown.
You can also use the variable in other nodes of the automated flow, for example in condition check nodes, by writing an expression with the syntax workflow.values.variableID.
This lets you make dynamic decisions within the automated flow, not just personalize content. For example, you can store the cart total in a variable and then:
- Send different communications based on the value
- Trigger a reminder only above a certain threshold
- Route contacts through different paths based on interests or specific behaviors
This way, your automated flow becomes more flexible and reacts in real time to the data you collect along the journey.
Check the value of the variable
To perform a test, start an automated flow test session.
Open the details of the current session and access the Variables section.
You will find the variables assigned with their current values.