VALIDATION

People do mistakes. Either intentionally or not. That’s a fact of life, and your chatbots should be prepared.

When you ask your chatbot users for data (like numbers, emails, or phone numbers), sometimes the response will be unexpected. So, it makes sense to check what exactly is in the user’s reply before placing that value into the user attribute and using it further in the conversation.

Once this block is executed, you can check the value of the $_validation_result system attribute to see if the value has a correct format. It will be true if everything is ok, and false otherwise.

This approach is a bit more complex than the common one used by other chatbot platforms like Manychat, for example, when you indicate the type of content you expect and add a hard-coded message to display if the value has an incorrect format. But it allows you to build much more flexible and intelligent conversations!

Here is a simple example that checks if the user’s email and phone number are correct and goes back to the LISTEN block if it’s not:

Notice the use of the SWITCH block to check the value of $_validation_result and proceed to the next block in case it’s true or display an error message and go back to the previous LISTEN block if it’s not.

Last updated