What you'll learn

  • What variables are
  • How variables can, and are used

Variables overview

Variables are the backbone of Voiceflow. Variables allow you to capture and store information to build better, more powerful, more personalized Alexa skills.

Variables in Voiceflow can be seen by the double curly braces around them, they look like this {{username}}. You can create variables for anything, and do a ton with them. 

There are two different types of variables in Voiceflow - local, and global variables. We'll get into those later in this piece.

Accessing the list of Variables

To open the variables tab on the side bar. It's the 3rd tab down from the top bar, with the </> icon.

Here, you can see all of the variables currently in your project, split between local, and global variables. You can also see the 3 default variable types:

  • {sessions}: the number of sessions that particular user has had
  • {user_id}: the unique Alexa user ID given to that particular user
  • {timestamp}: the time, in UNIX time, in which the user started that session
  • {platform}: the platform your project is running on ("alexa" or "google")
  • {locale}: the locale of the user (eg en-US, en-CA, fr-FR, it-IT ...)
  • {access_token}: the token you get with account linking and OAuth.

Global vs Local Variables

Global Variables
Global variables are active throughout your entire project. This means that they can be accessed within any flow, regardless of if it's a sub or ROOT flow. If you set a variable {name}, that variable can be found within every flow in the project. These variables are best used for data that is found throughout the project, such as a player's {score} in a game, their {name}. 

Local Variables
Local variables are found & active only within the flow you are currently in. If you are in the ROOT flow, and move into a subflow, then the local variables will be different between the ROOT & subflows. Local variables are useful when you want to perform a quick, particular function within a single flow. An example would be performing a loop using a variable called {loop} in which that variable only exists within the context of the particular flow you are in.

Deleting Variables

You can delete variables in this variable menu, however, if you delete a variable and the variable is used throughout your project, you will need to change the places the variable is used.

Variables are automatically set to the value 0

Your variables in Voiceflow are automatically created with a starting value of 0. To change the value, you must use a SET block.

How to name variables

Name your variables something descriptive of what information you are storing - such as 'name' for a user's name, or 'num_player' for the number of players. 

Some don't dos:

  • Don't add the curly braces for the variable name, Voiceflow does that for you
  • Do not use spaces, special characters, or duplicate variable names

Variable types

Variables in Voiceflow can be either numbers or words. More variable types are coming. The typical 'developer jargon' you might see online to describe these variable types are:

  • Strings: Strings are just a fancy way of saying 'words'. 
  • Integers: A fancy way to say 'numbers'
  • Floats: A fancy way to say 'numbers with decimal points'

How Voiceflow deals with numbers

If a word is detected that is a number, such as 'fifty' or 'ten', Voiceflow will automatically convert the word to a number value. This allows you to perform mathematical operations without type errors (multiplying a word by a number - impossible).

Still have questions? Be sure to post in our Forums to get fast answers!

Did this answer your question?