Store the End User Reply in a Custom Variable

In this article, we will explore the use of Custom Variables in Modules. We will provide examples of the following ways in which you can apply them:

Storing the end user reply as a name

First, we'll explain the method of saving an end user reply as a name. Because a name is just a string of text, this method is applicable in any use case where you have to store text comprised of standard characters.

Custom-Variable-Name.gif

The first thing you need to do is determine the purpose of the Module. In this example, the purpose is to collect the end user's name, hence the Bot Message, "What is your name?".

Next, check the box marked "Store End User Reply in a Custom Variable". This will allow you to input text into the fields "Name" and "Value".

Finally, choose what you want to call the Custom Variable. In this example, we are opting for something that is very easy to recognize: "user_name".

After you've saved your changes, hit refresh (F5), and the Custom Variable will be selectable in other Modules. Try including it in one of your Modules, as shown below:

recording__3_.gif

Save your changes one more time, then test your bot. This is how the conversation looks with the changes we've made:

Screenshot_2021-06-03_112153.png

As you can see, this allows you to add a lot of useful personalization to your bot.

Storing the end user reply as an email

Next, we'll explain how to save the end user reply as an email. For use cases that require validation of the end user input (such as determining whether the response is actually an email address), we recommend using Collector Modules.

In this example, we will be using the Email Collector Module, an overview of which you can see here:

email-user.gif

As with the previous process, you must first determine the purpose of the Module. In this example, the purpose is to collect the end user's email address, hence the Bot Message, "What is your email address?".

Next, check the box marked "Store End User Reply in a Custom Variable". This will allow you to input text into the fields "Name" and "Value".

The third action you need to perform is to choose what you want to call the Custom Variable. In this example, we are using something that is very easily recognizable: "end_user_email".

Lastly, you will need to input some error messages in order to ensure that the end user inputs a valid email address.

After you've saved your changes, hit refresh (F5) and the Custom Variable will be selectable in other Modules. Try including it in one of your Modules, as displayed here:

recording__4_.gif

Save your changes one more time, then test your bot. This is how the conversation looks with the changes we've made:

Screenshot_2021-06-03_113759.png

Storing the end user reply as a phone number

Now, we'll explain how to save the end user reply as a phone number. As noted previously, for use cases that require validation of the end user input, we recommend using Collector Modules.

In this example, we will be using the Phone Number Collector Module, as shown here:

phone-number-user.gif

First, determine the purpose of the Module. In this example, the purpose is to collect the end user's phone number, hence the Bot Message, "What is your phone number?".

The second thing you need to do is to check the box marked "Store End User Reply in a Custom Variable". This will allow you to input text into the fields "Name" and "Value".

The third step is choosing what you want to call the Custom Variable. In this example, we are opting for something that is easy to recognize: "end_user_phone".

Finally, you will need to input some error messages in order to ensure that the end user inputs a valid phone number.

After you've saved your changes, hit refresh (F5) and the Custom Variable will be selectable in other Modules. Try including it in one of your Modules, as represented below:

recording__5_.gif

Save your changes one more time, then test the bot. This is how the conversation looks with the changes we've made:

Screenshot_2021-06-03_113759.png

Theoretically, you can put in as many Custom Variables as you'd like in a Bot Message. This means that instead of sticking to relatively simple sentences that only return one Custom Variable, as seen above, you can string all of them together at once, as shown below:

stringCVars.jpg

Tagging end users who have accepted the GDPR terms and conditions

Here, we provide an explanation of how the flow should be structured when tagging specific end users with certain values. In this example, we'll be using GDPR as a subject, but the structure can be applied to any tag that you want to assign an end user.

screenshot-me.botxo.co-2019.08.23-15_56_27.png

The first Module that we recommend creating when tagging end users is a Statement Module that asks whether they accept or decline the GDPR terms and conditions, as seen in Module <md>154360:

screenshot-me.botxo.co-2019.08.23-14_10_25.png

Next, you will need to send the end user to a Module based on their response. In this example, we send them to Module <md>154361 if they decline, or Module <md>154362 if they accept.

In these Modules, we create a Custom Variable named Accepted_GDPR, but instead of using the end user's reply, we hard-code the values "false" and "true":

true-and-false.gif

This allows us to tag end users based on whether they've accepted or declined the GDPR terms and conditions.

Module <md>154365, marked in purple, represents any flow that you might have in a bot. In this case, it's only one Module, but it could theoretically be any number of Modules. The important thing to remember here is that everything preceding this Module (marked in teal) is there to assign a particular value to the end user. 

In your flow, there might be a time when you want to exclude content from end users who have not accepted the GDPR terms and conditions. This is where the Modules marked in red (<md>154657, <md>154658, and <md>154673) are particularly useful because they force the user to either accept the terms and conditions or end up in a part of the flow where their journey can no longer continue. 

Was this article helpful?

0 out of 0 found this helpful
Have more questions? Submit a request

Comments (0 comments)

Please sign in to leave a comment.