Skip to content

Set variables

Compute values once, such as a clean name, a total or a date, and reuse them in later steps.

What it does#

Set variables works out values and saves them for later steps: the first name from a full name, a total price, a date next week. The customer doesn't see this step; the chat moves straight on.

Use it when you need a calculation. To simply keep an answer under another name, use Save answer to (optional) on the question itself. If you don't see Set variables in the Steps panel, it isn't available in your account yet.

Set it up#

  1. 1

    Add and connect the step

    Drag Set variables onto the canvas, connect the step before into it and connect it to the next step.

  2. 2

    Name a row under Variables

    Under Variables, type a name such as firstName (letters, digits and _, starting with a letter).

  3. 3

    Write its expression

    Next to the name, write how to compute it, for example first(split(trim(@fullName), " ")) or number(@guests) * 150. Looks good means it can be read. See Expressions for what you can write.

  4. 4

    Test expression

    Click Test expression, fill Sample variables (for example @fullName = Dana Levi) and click Run to see the Result.

  5. 5

    Add and order rows

    Click Add variable for more rows. Rows run top to bottom, so a row can use the ones above it. Use Move up, Move down and Remove variable to rearrange.

  6. 6

    Use the result

    In later messages write {{@firstName}}; in conditions and expressions write @firstName.

What your customer sees#

Nothing. To show a result, use it in a later message, such as Thanks, {{@firstName}}! Your total is {{@total}}.

Common problems#

ProblemWhyFix
A variable is empty in a later messageIts expression failed for this customer, for example number() on textTest with realistic samples; add a fallback such as default(@city, "Tel Aviv")
A row can't use another rowThe row it reads is below itMove the row it depends on higher
This is a system variable. Choose another name.cphone, channel and now are reservedChoose another name
Start with a letter and use only letters, digits and _.The name has spaces or symbolsRename it, for example first_name
This name is set above too; this row wins.Two rows use the same nameRename one of them
Unknown name. Check the spelling, or type @ to pick from the list.The expression reads an answer that doesn't existPick it from the @ list