Last updated December 29th, 2018

What you'll learn

  • What IF blocks are, and how they work
  • When and how to use IF blocks

Video tutorial:

What is an IF block?

The IF block allows you to check to see if the user has hit certain conditions, and perform different actions if they have. 

Example 1
IF the user said they live in Seattle, send them down the #2 path. IF not, send them down the Else path.

Or

Example 2
IF the user's score is 10, end the game. IF not, keep the game going.

How does the IF block work?

Within the IF block you can create 'conditions' that are numbered. You can create up to 20 different conditions within a single IF block.

When you add an IF Statement, you will see the IF block expand. Each IF statement you add has a number beside it which corresponds to the number on the IF block.

Above, you can see the #1 Statement corresponds with the #1 port on the IF block.

If the condition we put in the #1 Statement is true when the IF block is activated, then the IF block will take the user down that path.

Adding conditions 

Conditions are the statements that we are checking to see if they're true when the IF block is activated. For example, one of our conditions might be: "{score} = 5". In this case, if the {score} variable was true as the user's score was 5, then that path would be activated.

Let's add a condition now:

Above you can see we have created a condition to see if {score} = 5. If the block is activated and this is true, the user will be taken down the #1 path.

If you are not familiar with building conditions in Voiceflow, you can check out our tutorial on that here.

Adding multiple conditions

When you have multiple conditions, Voiceflow will check each condition starting from #1, and moving down to your last condition.

Your Alexa skill will go down the first condition that is 'true'. As an example if your #2 and #8 conditions are both true, the #2 condition will be the path that the user takes as it is checked before the #8.

When no condition is true

If the IF block is activated and none of the conditions are true, the ELSE path on the IF block will be activated. 

Still have questions? Message our team using the blue chat bubble in the bottom right corner!

Did this answer your question?