Using variables in your WhatsApp flow
If you’d like to reference a variable that is obtained from a step within the Whatsapp flow, such as a user response or a validation status, you can save and reuse a contact response to a previous step as a variable in the following steps of your flow.
Accessing and using variables
The notation for variables is as follows:
{{.<block_name>.<variable_name>.value}}
To access the content inside the brackets:
-
Select the Open Question box in Truora’s dashboard. This action will automatically open a panel on the right side. Scroll down to the Variables section, locate the desired variable (as highlighted in the red rectangle), and click the copy icon to copy the reference of the variable you want to your clipboard. In the case shown in the image, the variable will contain the answer of the user to the displayed question:
-
Paste the copied variable into the block where you want to use it. The text editor will automatically detect the variable reference and display a pill with the block title:
Note: You cannot use variables in button names.
-
Save, publish and test your flow. The image below is an example of how it would work on WhatsApp:
Include Variables in a Conditional box
- Drag the Condition box from Advanced Blocks and drop it into the Truora dashboard. Click on it to open the panel on the right side.
- In the If this… field select the Variable option.
- Paste the value of the copied variable in the With value field. The system will immediately recognize the variable.
- In Has the following condition field, select one of the following conditions:
- is equal to
- is different to
- contains
- contains one of
- is greater than
- is greater than or equal to
- is less than
- is less than or equal to
- is empty
- is not empty
-
In the Fulfills field, type the value of the open question that fulfills the condition.
Note: Each conditional logic block has two outputs, green and one red.
- Green output is triggered if the condition is true (in the example above, if
greeting.value
equals “John Doe”). - Red output will be triggered if the condition is false.
- Green output is triggered if the condition is true (in the example above, if
-
In the Add condition option, you may create up to 9 different conditions.
-
Finally, test your flow!
Use the variables of an outbound message in the flow
You can use the variables of an outbound message inside a flow as inputs for any block.
To call the variables use the following syntax: {{.start.<variable_name>.value}}
. For example, using the variable name from the previous image, you can call the variable as follows: {{.start.name.value}}.