Help your chatbot recognize integer numbers.
The integer number entity is a system entity that helps your chatbot identify when the user writes the integer number.
How does the integer number entity work?
The integer number entity must contain integer numbers (e.g., 1, 7, 97, 3073). When the user enters some numbers in a chat, the chatbot compares it with the integer number entity and checks which number is the integer number.
The integer number entity lets you automatically validate numbers. You can save them as attributes and use them later in a conversation; for instance, to confirm orders in your online shop, prices, and more. Data gathered through attributes can also be sent to external services so you can reuse it for other purposes.
How to use the integer entity
Let’s say you run a restaurant, and you let your customers order pizza by using a chatbot. The system integer number entity can help your chatbot verify how many pizzas a customer wants to order.
-
Open a Story you want to use to collect orders from your customers.
-
Add a Bot response in a place where you want to let the customer select their pizza.
-
Open the Bot response and add some Text and Gallery responses to present different types of pizza to the customer.
-
Open the button field in the card — type in the Button title, and select Send message in the Button type field. Then, add the Postback value — a type of pizza the user can order. Repeat this setup for every card.
-
Next, add the User input after the Bot response to collect the user response.
-
Open the User input and select the double curly brackets to trigger the entity window.
-
In the Parameter validation field, select the Any system entity.
-
After verifying the user’s reply, you can save it as an attribute. To do so, select the Save to attribute and create a new pizzaType attribute. Then, click the Add attribute button.
-
Now, you need to ask the user how many pizzas they want to order. To do so, add the Question action after the User input you added. This action lets you add multiple questions and collect user input at once.
-
Open the Question block. In the Question variants field, type your question. You can add a custom pizzaType attribute to confirm the data you gather in the User input.
-
Now, in the Validate response with entity select the Integer system entity. This way, your chatbot can recognize integer numbers
-
Once the user response is validated, you can save it into an attribute. In the Save response to attribute field, add a custom pizzaNumber attribute**.**
-
Now, in the Action on failure input, decide what should happen if the user fails to provide the integer number.
-
After collecting the user response, your chatbot can confirm the collected data with the user. To do so, add a Bot response after the Success block.
-
Open a Bot response you added. Use the collected attributes and compose the chatbot’s reply.
-
You can make your chatbot’s communication more accurate by adding filters. Filters let you display a different message to users depending on the information they provide. So, let’s say you want to send a dedicated message to users who order just one pizza. To do so, select the Add filter button.
-
In the Attribute name field, select the pizzaNumber attribute. Then, add =equals in the Condition section and set Value to 1.
-
Now, you can create a message for users who order more than one pizza. To do so, add another Text response and write the matching chatbot reply.
-
To display a message only to users who order more than one pizza, select Add filter.
-
In the window that appears, select the pizzaNumber attribute. Then, set up the condition to be greater than 1. This way, your chatbot will show this message only if the user orders more than one pizza.
-
Finally, test your Story to verify whether everything works as intended.