How to use chatbot variables

Chatbots are rarely as matter of static texts and buttons. Displaying dynamic information, changing the flow of the chat according to a value or even just greeting your users by their name: all of these actions and more can be done using Xenioo variables.

Variables are values that are associated to a unique name. As an example, a variable named first_name could hold the value Mary. Using the variable anywhere in Xenioo will be a matter of referencing it by name: Xenioo will do the work for you of changing it to the actual value.

Built-in Variables

Right out of the box, Xenioo will create for your chatbot a number of variables ready to be used and already filled with the correct data it can extract from the active channel!

Creating or updating a variable

To create a variable or change its value you can use the Set Variable Action. This action let you set the value of any variable. If the variable exist, the value will be updated otherwise a new variable will be created.

To avoid unnecessary use of scripting, Xenioo offers a number of built-in operations to apply to your values right out of the box. Adding, merging, clearing values can be done with just a single action.

Xenioo: Creating or updating a variable

Using a variable to change the chatbot flow

Many times the flow of the chat needs to be changed depending on the value of one or more variables. Think about a chatbot that shows different products based on the user sex or that offers different services based on the country of residence.

To change the flow of your chatbot based on the value of a variable we use a Variable Switch Action. Using Variable Switch Action we can check the value of a variable against a number of criteria such as equals, contains, greater, lesser and so on. If the criteria check is successful any subsequent operation will be executed. From a developer standpoint, this is the foundation of any IF…THEN statement.

Xenioo: Using a variable to change the chatbot flow

Dynamic Variable Parsing

The concept of Dynamic Variable Parsing is that everywhere in Xenioo you can reference the value of a variable so that at runtime, as the chatbot talks to your user, the actual value is replaced in real-time.

Variable referencing is done by putting the variable name inside two curly brackets. If you want to reference first_name, just type anywhere in your chatbot actions {{first_name}}. It does not matter if it is either a text bubble, a button text or even an API call: Xenioo will retrieve the variable value and replace it with the referenced name.

Xenioo: Dynamic Variable Parsing