How do I set up the Set Variables step?

Write text, a calculation, a date or a list summary to variables, and use the results in later steps.

What is it for?

“Set Variables” writes a value to one or more variables. If you give the name of an existing variable, its value changes. In later steps you use the value as {name}.

Visitors don't see this step and the avatar doesn't say anything; the agent carries on without waiting for the visitor.

To add it, click “Add step” on the “Flow” tab, then click “Set Variables” in the “Logic” category; the step is added in the middle of the canvas. Its settings are on the “Content” tab of the step panel that opens on the right when you click the step.

This step has no “On-screen text”; instead there's a “Step note” at the bottom of the panel. The note is just for you: visitors don't see it, and it isn't spoken or translated.

In values you use variables from earlier steps, like {city}. For a field inside an answer, add the field's name after a dot: {order.status}. The “Insert variable” button in the boxes lists the variables you can use at that point. A variable that hasn't been filled yet counts as empty text.

Setting up the step

  1. Type the variable's name in the first box under “Assignments”. A new assignment suggests a name the agent doesn't use yet; you can change it.
  2. Choose the value type in the list next to it and enter the value below.
  3. For another variable, click “Add assignment”; remove extras with the cross button on the row (“Delete assignment”).

Value types

  • “Text”: the text you type, which can include variables ({first_name} {last_name}). If you leave it empty, the variable is cleared.
  • “Calculation”: numbers, variables, + − × ÷ (or * and /) and brackets, e.g. {total} * 1.2. Multiplication and division come first. The result is a number with at most two decimals (12.5).
  • “Date”: adds an amount of time to a start date; the unit is days, weeks, months or years. If the start box is empty (it shows “Today”), the visitor's today is used; a negative amount goes back in time. The result looks like 05.10.2026. A date past the end of the month moves to the month's last day: adding 1 month to 31 January gives 28 (or 29) February.
  • “List summary”: turns a list into a single value. The operation is “Count”, “Sum”, “Average”, “Smallest”, “Largest” or “Join”; Join writes the values side by side, separated by commas. For anything but Count, enter the item's field to use in the box next to it (e.g. price); with no field, the item itself is used. On an empty list, count and sum are 0 and the others are empty.

Assignments run in order; a later one can use the value an earlier one wrote. A value that can't be worked out (a variable that isn't a number, division by zero, a start that isn't a date) clears the variable, so the agent doesn't carry on with an old or wrong value.

Example

An event sign-up has three assignments: total (“Calculation”) {guests} * 25; total_with_tax (“Calculation”) {total} * 1.2; due_date (“Date”, empty start, 7 days). A Message step can then say “Your total is {total_with_tax}; please pay by {due_date}.”

Things to watch out for

The editor warns you when: there are no assignments, an assignment's name is invalid, a “Calculation” or “List summary” value is empty, or a calculation has a typo.

Variable names can only use the letters a–z, digits and underscores (_); accented letters and spaces drop out as you type. “system” is reserved for system variables, so pick another name.

Problems don't stop you saving: the agent is saved, but the incomplete step won't work as expected in the conversation. Fix the flagged steps, then try the agent with “Preview”. To find flagged steps, see the flow editor.

Related articles

Was this article helpful?

Agenola and our partners use cookies to improve the site and show you relevant ads. We count which of our ads bring visitors without using your name or email; anything more only happens if you allow it. Privacy Policy(opens in a new tab)