Getting your clients` phone number is an easy and natural way to stay in touch. Thanks to the system entities, your bot can do it for you.
The phone-number entity helps your bot to recognize phone numbers in all popular standards — with country code, dashes, and brackets. The system checks if the user input is correct and memorizes the given contact number so you can reuse it in the ongoing conversation or pass it to your web services and databases.
Chatbot example with the sys.phone-number entity
Your bot isn’t omniscient and even its best configuration may leave some of your clients without the answer. In this quick example, we’ll build an interaction that collects the phone number from clients that ask questions that cannot be recognized by the bot.
Type double curly brackets
...to trigger the entity window and select the one you you need.
Create a new storyand name it
Get phone number. Inside the story
add a new interactionwith the same name. Ask a Question is the best bot action to collect user data. Add it to the bot responses.
- Type your message and
select the phone-number system entityas the validation type. Also, decide the name for the new attribute.
Add a text messageto confirm that the phone number has been saved.
Let’s connect this interaction with the default fallback interaction.Add the following filter:
Lifespan > 0to your default fallback response.
When the fallback equals 0, order your bot to ask for the phone number. To do so,
add the go to action that jumps to our Get phone number interaction.
Saveyour work and test out the bot.