Creating Variables

Tahsim Ahmed
Tahsim Ahmed

Introduction to Variables

Variables can be contextualized as container(s) that allows them to have data/information stored inside of it, and to be able to be used elsewhere or recalled at a later time. In Voiceflow, the importance of variables can be seen in this simple exercise.

Ex. Let's say you want to personalize your conversational assistant by the user's name. The below screenshot outlines one introductory method in order to do so:

Note that the above example is not entirely scaleable, and it would not be feasible to remember every user's name manually. Furthermore, the above example would only work if your user's name was actually Joe, and this would not be dynamic (or personalized).

Tip: For information you expect to get filled or can vary and there is a need to be contained, you will want to use variables

Here is the above example improved, with variables:

For educational purposes, you can quickly test & simulate and see this variables in-action!

Note: The below method replicates a use case of what the Set Step accomplishes, but the changes/variable declarations are only test-specific and unique for that specific design-test session and not in your assistant.

To do this, start with testing your experience by hitting the blue Run (shortcut R) button:

  • Navigate to Variables sidebar, when in Test mode under the Test Tool on Canvas
  • Set the value of your desired variable by inputting in the desired field in the Variables menu or setting your desired Variable State/Persona (testing with Variables).
  • You can then Run Test:
Tip: You can learn more about testing & prototyping with Variables and their state(s)in this doc here.

 

How do I create a variable?

You can create variables in your assistant in multiple different ways:

  • In any Talk Step type, start typing in the input field with the left (curly) brace '{' and hit Create
  • In the Condition Step, in any of the If (Add a condition) fields with the same method above
  • In the API Step, in any of the input fields with the same method above
  • In the Agent CMS under the Variables page
Tip: You can use the curly braces { } to create new variables, but also scroll through and invoke and add pre-existing or previously defined/created variables in your assistant

With any of the methods to create variables above, you can create variables explicitly (or plan for future use of variables) or on-the-fly and as needed with opening curly braces.

Tip: Variables are broken down as pieces (containers) of logic dedicated towards programming and conversation design, so therefore the variables must be lower-cased and contain no-spaces

The next sections cover some of the options and steps available in Voiceflow in order to manipulate/alter, perform functions/expressions and end-to-end commands with Variables.

Note: Though behaving similarly, Variables and Entities in Voiceflow are commonly confused. Learn more about how each data/logic type operates in this doc here.

Was this article helpful?

3 out of 14 found this helpful

Have more questions? Submit a request

Comments

1 comment

  • Comment author
    Anand Vijay

    Hi How can i pass variables using cookie or something from my website to the bot. Example name and auth token. I dont want to ask users of these details.

    0

Please sign in to leave a comment.