A variable is a placeholder that you can use to customise part of a chatbot message without creating extra passages.
Variables are designed to keep a value for a user so it can be re-used in multiple passages. Each variable is created to hold one piece of information, like a name or option selection, and the value is specific to each user's conversation.
The variable's value is assigned by actions that are triggered by the user's interaction with your chatbot. If the chatbot tries to use the variable before a value has been assigned, it will use a default value, or a blank value if there's no default.
In this guide, we're use the variable to address our user by name, and a blank value in the message would look strange. To prevent that, we'll set a default value when we create the variable.
Let's create a variable for our user's name:
- Open the Create section of the left-hand navigation.
- Click Variables.
- Click + Variable.
- Type Username as the name for your variable.
You'll use this name to add the variable to your chatbot content. Variable names should be short but descriptive, and can use letters, numbers, spaces, and punctuation.
You can change a variable's name later if you need to. - Click Create.
- In the Description field, type Chatbot user's name.
- Select This variable requires a default value.
- In the Value field type friend.
If the variable value hasn't been assigned when we use the variable, the chatbot will use 'friend' instead. - Click Save.
We've created a variable to capture our user's name and added a default value to use. Now, let's create the passage where we'll assign a value to it.
Comments
Article is closed for comments.