Add input validation for email and name in Einstein Bot.
Posted on October 30, 2020
Hi Trailblazers, In this blog post We are going to add validations while answering Einstein Bot questions.
Before we start, I'm assuming you have knowledge of Einstein Bots, Web chats, and Intents/Utterances.
Useful links.
https://heysalesforce.org/posts/how-to-put-einstein-bot-on-any-website-using-salesforce
Why we need validations on input?
Validations prevent wrong entry and increase data quality.
In Einstein Bot, Sometimes Bot asks for important information for follow up. In this case, we don't want users to write the wrong email formal or name.
Walkthrough:
1. First We'll create a dialog asking for contact information.
2. After that, We'll create entities for Email and Name.
3. We'll add a Validation Message for it.
Let's Start:
Open your Einstein Bot Builder.
Setup > Einstein Bot

In Einstein Bot Builder, Welcome Dialog.
Add a question - What is your good name?
Check the following picture.

Add 1 more question - What is your email?

Now create two Entities:
Name : nameCheck
Regex : [a-zA-Z] //we dont want integers.

Name : emailCheck
Regex : [a-zA-Z0-9._-][email protected][a-zA-Z]+.[a-zA-Z]{2,4}
![[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}](https://heysalesforce.org/images/posts/1604084315.png)
After creating Entities,
Now we need to add these newly created Entities to questions.
And for validation message, We'll add a Conversation Repair.
"Please add a name in Alphabets"
Check the following picture.
For Name:

For Email:
And for validation message, We'll add a Conversation Repair.
"It looks like you didn't enter a valid email,
Like [email protected]"
Check the following picture.I

We're all set now.
Let's test it out.
Click on the right bottom for a chat.
After loading it, It'll ask for your name.
Check the following image.

And for email.

As you can see, It's working now.
This is how We can add validation in the input.
I hope It helped you somehow.
If you have any question Ask Me
Thanks for Reading:
Write a comment for suggestions.
Tags: #EinsteinBot
Comments
-
Denise Moore - 6 months ago
what about email addresses that aren't that standard formatting, like [email protected]