07 – Working with chatbot variables and tags | Video Course

Working with Chatbot Variables and Tags

What you will learn?

The goal of most chatbots is being able to capture as much information as possible from conversations. Profiling users and knowing their data is necessary to better assist them and improve the quality of the responses. The way Xenioo acquire and persist specific piece of information for each conversation is through the use of chatbot Variables and Tags.

Chatbot Variables

A variable can hold just about anything. Most people use it for truly custom text (like a first name), but it can also be used to segment your audience.

What is a variable? A Xenioo variable is an entity defined through a name and value pair. Each variable has a name and an assigned value.

While variables are defined globally during chatbot design, their values are persisted independently for each single user conversation. For example, if you define the variable favorite_pizza in your chatbot flow, all conversations will bring it and each conversation may have a different value assigned.

As you can see in the Xenioo documentation, there are several types of variables you can look at.

Default Variables

The first type is Default Variables, which are variables that are automatically added to your chatbot runtime by Xenioo.

These include some fundamentals, such as user first_name, last_name, user_id, and bot_channel, just to name a few.

Chat State Variables

The second type of variable indicates the chat state value, which may contain the following values, depending on the current state of the chat: 

  • empty/unset“: Xenioo controls the chatbot flow. It’s the default state, where the chatbot responds to user input accordingly to the flow.
  • operator requested“: the conversation is waiting for human intervention.
  • take over“: the conversation has been taken over by an operator and it’s currently managed by a human. Chatbot stop to respond to the user input.

Privacy Variables

Privacy-related chatbot variables are a special type of variables that cannot be altered in any way from outside or inside the chatbot runtime.

privacy chatbot variables

These variables hold the selected privacy preferences of your user and only a Privacy Opt-in Action can alter these variables.

Chatbot Tags

In addition to variables, you can also use tags. A tag is simply an on/off indicator: if users are tagged “Customer”, they’re customers. Otherwise, they’re not customers.

Tags are single named entities that can be attached to the conversation. They are usually used to later filter or switch the flow based on their presence or absence. If you do not need to store a value but you need to represent a simple flag, tags are generally better.

By default, your chatbot will have the New_User” tag, which is assigned to users who are starting a conversation for the first time.

In the image below you can see a flow I built just to see how you can typically handle a tag.

chatbot tags

As you can see, I ask the user to tell if he is a man or she’s a woman. I use two buttons (2) to detect the user response and set the tag to the value “male” or “female” (3). Then I use a switch condition action (4) to redirect the user to the proper interaction (5) based on the value of the tag.

This is a very basic example. However, it gives you a clear indication of what’s going on and how powerful could be the use of tags.

Switch Condition Actions

So far I’ve used just tags: if the man or woman tag exists, then do something.

An optimized flow could be something like this:

condition actions

I’m asking the user if he is a man or woman (1), then wait for a user reply (2), and finally, check for its value and move the conversation ahead (3, 4).

The Text Input Action deserves a closer look:

chatbot text input

This action put the conversation on hold until a valid input from the user. User input is validated against any given regular expression, like “female” or “male” (1). Input is then saved inside a Target Variable (2) which in this example is called “gender”.

The Wrong User Input Reply is what the bot responds to if the validation fails (3). You can specify more answers, one for each row, which would be chosen according to the criteria specified in the Reply Pick Mode (4).

Max Wrong Answers (5) is the maximum number of wrong inputs the user can send before the question is skipped. It defaults to 0 (zero) to never give up on wrong inputs. The conversation is taken on hold until user input is valid or until the user if allowed, skips the question (6).

Right after that, I’ve configured two Variable Switch Actions to check variable value:

chatbot variables switch actions

Basically, I’m telling Xenioo something like: “if the variable gender contains the value man (1), then Go To a specific Interaction (2)”, otherwise, “if the variable gender contains the value woman, then Go To another Interaction.

Testing the preview of this behavior will then generate this conversation: the chatbot asks for my gender, I reply with “male”, so I get the answer just designed for a male user.

chatbot variables

Using the Variable Switch Action to execute operations based on the value of an existing variable you can, like I showed in this example, change the conversation flow redirecting the user to a different interaction.

The same could be accomplished even for Tags using the Tag Switch Action and it works the same way.
You can find both actions in the “Flow” category and they’re named “Tag Conditional Switch” and “Variable Conditional Switch”.

variable condition switch

Chatbot Privacy Variables

As I mentioned before, Privacy Variables are very special variables. They are protected and can only be set up using the corresponding  Privacy Opt-In Action. There’s no way to alter this variable value once is entered by the user in the conversation.

You can use this action to display a privacy opt-in request flag to the user. The user should choose to either accept or refuse your privacy terms. A file containing terms may be uploaded as Html or pdf.

As you can see in the image below, I’ve configured the privacy action to display my chatbot name.

privacy chatbot variables

Dynamic Parsing

Xenioo Dynamic Parsing lets you specify any variable inside any action or operation text field. Every variable will then replaced with its current value at runtime.

privacy chatbot variables

Dynamic Parsing is supported in all text fields you can find in any actions or operations. You can even access a user-friendly editor just by clicking the small button that should appear in the top-right corner:

This button opens up the Variables Text Editor. From this editor, you can write your text and easily pick any variable you need to use in your text.

You can find detailed information on how Dynamic Parsing works from our online help.

Privacy Flag Switch Condition

Let’s go back to the privacy flow:

privacy flag switch condition

After the Privacy Opt-in Action (1), I need to check if the user has accepted our privacy policy or not. Since the privacy variables are protected and cannot be manipulated like other variables, I must use a specific action to check them: Privacy Flag Condition (2, 3).

Using this action is very straightforward. I just have to decide between two values: “Enabled” and “Disabled” that correspond to the value assigned by the user “accept” or “refuse” response.

Use the “multichannel” variable

As I said previously, Xenioo provides a specified variable that identifies the channel the conversation is running on. This variable is named “bot_channel”.

This variable is very useful when you are building a multi-channel chatbot and need to optimize the flow for each specific channel.

Imagine having a user in your chatbot who expresses a clear purchase intention. If he is on the Facebook channel, it might be convenient to suggest that he visit your page’s Facebook Shop, for example. If, on the other hand, he’s chatting from the Web Channel, it would make more sense to link the page of your e-Commerce.

As you can see in the image below, I’ve optimized this example flow to best accommodate both scenarios.

To Sum Things Up…

As you have seen, chatbot variables and tags are fundamental tools we can use to create more functional, effective, and personalized conversations.

In the next lesson, we’ll proceed to more advanced topics, like how to effectively make questions and ask information.