How to use global variables and user responses in a chatbot

When constructing a script for your chatbot you can store the messages your users are entering and then reuse those messages by referencing them inside your script. Learn more at How to create conversation scripts.

You can use global chatbot variables inside messages, html components, reports, web services (API), among others.

To learn how to create reports from global variables read this tutorial.

Every script includes one global variable by default. It is called {userid}, and is the User ID of the person currently interacting with the chatbot or phonebot. For Phone, SMS and whatsapp, it will be the phone number of that person. For Telegram, Facebook and others, it will be their internal ID for those services.


Take this example. You are an online store and you want to direct potential customers to their products of interest. 

First go to Scripts>Create New and create a new script. 

Start the conversation and ask their name. To store the response you will need to use the Input Component.

The Input component will save the response so you can use it later in the conversation. The Form and condition components also store user messages.

You can check for any variables saved by clicking on the Variable button at the top.

You can use the variables inside a message, for example, after you ask for their name, you can include their name in the conversation.

Continue the conversation by asking them their product of interest.

After they enter their product of interest you can use that variable to look in your catalog (through and API) or look inside a website.

Take the Web Service example (API). Enter the variable inside the API route to make a request. The request in this example will output a link.


You can also simulate the conversation as you are constructing by clicking the Simulate button. Here is the simulation for this conversation.

You can also use your variables to create reports and send them to a specific email.

Save the script to continue. You can install the script in a messaging app, a website or for a specific webpage.

Would you like to know more?

Get more information