How to use variables
A guide on how to use Variables in your chatbot
Variables can be used for capturing information, displaying dynamic content, and processing data in your chatbot.
How to store data in variables
You can store data in variables using the Store answer in variable
or a similar option that’s available for certain blocks in the builder. This option appears in the block editor.
Let’s take the Text input block as an example. This block allows users to enter text. To store the user’s response in a variable, click the dropdown below the Store answer in variable
option and select a variable.
How to display variables in messages
You can display variables in messages using the {variableName}
syntax. The variable name should be enclosed in curly braces.
As an example, let’s you have a variable called first_name
and you want to greet the user by their name. Here’s how to do it:
- Add a Text output block to your chatbot.
- Click the block to open the editor.
- Type
Hello, {first_name}!
in the message field.
- When the chatbot displays this block, it will replace
{first_name}
with the value stored by the variable.
Note that the values stored are on a per-conversation basis. This means that the value of a variable is unique to each conversation and is not shared across different conversations.