In this article, we will explain the use of Custom Variables in modules, and provide a few examples of the ways in which you can apply them.
We will go through the following:
- Storing the end user reply as a name
- Storing the end user reply as an email
- Storing the end user reply as a phone number
- Tagging end users that have accepted the GDPR terms and conditions
Storing the end user reply as a name
This use case explains the method of saving the end user reply as a name. Because a name is just a string of text, that means that this method is applicable in any use case where you have to store a text comprised of standard characters.
The first decision you need to make is to 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?". 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 and last thing you need to do is to choose what you want to call the Custom Variable. In this example, we are opting for something that is very easily recognizable, "end_user_name".
After you've saved your changes, hit refresh (F5) and the Custom Variable will be selectable in other modules, as shown below:
Save your changes one more time, and test the bot. This is how the conversation looks with the changes we've made. As you can see, this allows for the option of adding a lot of personalized messages to your bot.
Storing the end user reply as an email
This use case explains the act of saving the end user reply as an email. For use cases that require validation of the end user input, we recommend using Collector Modules. In this example, we will be using the Email Collector Module.
The first decision you need to make is to 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?". 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 action you need to perform is to choose what you want to call the Custom Variable. In this example, we are opting for 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, as shown below:
Save your changes one more time, and test the bot. This is how the conversation looks with the changes we've made:
Storing the end user reply as a phone number
This use case explains the act of saving the end user reply as a phone number. 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.
The first decision you need to make is to 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 action you need to perform is to choose what you want to call the Custom Variable. In this example, we are opting for something that is very easily recognizable, "end_user_phone". Lastly, 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, as shown below:
Save your changes one more time, and test the bot. This is how the conversation looks with the changes we've made:
Use as many Custom Variables as you want
Theoretically, you can put in as many Custom Variables as you'd like in a Bot Message. This means that instead of doing relatively simple sentences, where you only return one Custom Variable, as seen above, you can string all of them together at once, as shown below:
Tagging end users that have accepted the GDPR terms and conditions
With this use case, we intend to give you an understanding of how the flow should be structured when tagging certain 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.
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 154360:
Next, you will need to send the end user to a module based on what their response was. In this example, we send them to Module 154361 if they decline, or Module 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":
This allows us to tag end users based on whether they've accepted or declined the GDPR terms and conditions.
Module 154365, marked in purple, signifies 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 here to remember 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 where you want to exclude content from end users that have not accepted the GDPR terms and conditions. This is where the modules marked in red (154657, 154658, and 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.
Please be aware that while the module-specific Custom Variable function is very versatile, there might be some edge cases where using the "BotXO Variable Creator" Webhook Template is more suitable.
Comments
0 comments
Please sign in to leave a comment.