- Print
- DarkLight
- PDF
In this article we're going to look at the True/false block.
Use this to test true/false conditions to direct a user down a particular path depending on whether the conditions are met.
"True/false" is typically used in conjunction with other blocks such as "Set a variable" which you can find in the "Advanced" category of the block builder.
Let's dive in!
TYPICAL USES FOR THIS:
- Testing a variable whether it is True or False.
- Providing your bot with logic that enables it to test certain inputs and/or direct users through decision trees based on the testing of those inputs against variables you have set here.
STEP 1: Add a new block.
STEP 2: Select the "Advanced" category.
STEP 3: Select the "Set a Variable" block.
The following window will appear:
Let's explore the elements of this page.
You have a few elements with which you can interact here such as:
- Conditions - which are made up of these sub-elements:
- @@Variable
- Operator
- Comparison Value
Let's start with "@@Variable".
You can either select from an existing variable, or simply type in a completely new one. For this example, we are going to create a new variable called "@@IsRegistered" from the example we set in our "Set a variable" article. For this example, we are going to test whether the user is registered based on the variable mentioned.
Let's set it to "@@IsRegistered"
Operator:
The Operator defines how you want to "test" the value of the variable you selected.
Select from the list of available drop-down options - for the purposes of this example, we are going to choose "Equal to".
Comparison Value:
Based on our example, we want to test if our "@@IsRegistered" variable is "Equal to" a value of "true".
Therefore, we must set the "Comparison Value" to "true" (to match the value set in our variable "@@IsRegistered" as follows:
STEP 4: Click on "Save" to save the the True/false block. At minimum, the following elements of this block must be completed:
- @@Variable you are testing.
- Operator you are using against the "Comparison Value" for your "@@Variable"
- Comparison Value - This may or may not be required depending on the operator type.
Example:
You can "+ADD NEW RULE" if you'd like to test more than one condition is met. Simply clidk on the blue button and complete the conditions as many times as required.
Result:
Once saved, you will see your True/false block will appear in your bot editor window attached to the last block onto which you added your "True/false" block.
From here, you can then continue building your bot by adding additional blocks taking whatever avenue you prefer.
Done! You've successfully used the "True/false" block.