Tahsim Ahmed
Tahsim Ahmed
  • Updated

How do I force assign or set values of variables to my assistant?

Often times in your conversation, you will want to alter variable values if a user reaches a certain point in your conversation or performs a certain action. Sometimes, you will want to reset values or alter them based on circumstance.

In Voiceflow, these specific instances where you want to 'forcefully' (manually) change or set a value of variable(s) in your conversation, requires usage of the Set Step. The Set Step allows you to set and change the value of variables.

Setting and Changing Variable Values

The Set step lets you change the value of a variable when the Set Step is activated. You can get started by dragging the Set step, from the Logic section in your sidebar. Don’t forget to assign a label to your set.

Tip: By leveraging Add Set in the Set Step menu, you can add and also change multiple variable values at once and the changes will take place from top-to-bottom. You can do this with the Add Set (3) button.

Next, you will want to choose a variable in the Apply To (2) input.

You can now set the value, variable ({ }) or expression you want to your variable in the previous step, by entering it into the Value Type section in the manner you want the variable to adopt.

Note:You can also set your variable to a specific text-value (String-value) but you will be unable to perform expressions or equations, as indicated in the next sections.

Setting Expressions - Adding and Subtracting

A common way to change a variable value is to increment it. To increment a variable means to increase it by the same amount at each change.

Ex.A conversation designer may increment a scoring variable by +2 each time a basketball goal is made. Decreasing a variable in this way is known as decrementing the variable value. A conversation designer may decrement a point total by –1 each time a user responds to a question incorrectly.

In the Set Step menu, you can also toggle to configure the Value Type to be a Variable or Expression. You can use the Expression field to increment or decrement variable values using the Set step.

To do this, select the variable you want to increment and then create the equation you want the variable to be equal to.

Ex. To increment a variable value by 5, select the variable you want to increment and set the equation to {variable} = {variable} + 5

Setting Expressions - Complex Equations

The Expression field also unlocks the possibility to perform a complex equations, which allows you to write JavaScript statements.

Tip: You can track how your variables are interacting in your conversation (and changing based on Set Steps) by turning on Debug Mode (Settings after you hit Run) while attempting to test your conversation on-Canvas


Was this article helpful?

10 out of 57 found this helpful

Have more questions? Submit a request



Please sign in to leave a comment.