I have built a flow where the bot collects user input in an entity node. The value from the entity node needs to be passed as the request body to a service node. The user input may contain invalid values such as ‘sfsrwsrg’, ‘sdfad342342’, ‘252342’, or ‘*(%^$&#%’, which should be validated before passing to the service node. How I can achieve this using the entity node or script?
Akash,
There multiple ways to validate an entity input, so the best method will depend on the format of the valid input value. I typically solve this challenge in one of two ways: use the custom entity type or use an script node after the entity collection.
The easiest way to validate (IMHO) is to use the custom entity type.
You can create a REGEX expression to check the format of the input. If the input does not match the pattern, the node will prompt the user to enter a valid value.
If the entity input value needs to be manipulated before validation, use a script node after the entity collection. Common use cases for a script node are to delete spaces (very common with voice channel entries), to remove (or add) special characters or to change capitalization (case). This method is slightly more complicated because if the input is not valid, you must clear the entity value, provide an error message and loop back to the entity node to recapture a valid entry. Something like this:
I hope this helps. Good luck!
Is there any other way to check the user input validation in the entity node value?
Yes, there are other ways, but you’ll need to help me understand what determines the validity of an entry. Please describe your flow and what the user is asked to provide. There are some pre-built entity types that might help capture what you need.
Please share screen shots of your dialog.
@botwhisperer
When the user enters input into the entity node (in my case, the user should input text like ‘I am looking for a possession form’ or ‘possession claim’) in the correct format, if they enter any random value (like ‘wgrweawegt’, ‘23uhierhw’, or ‘@#$%^’ or single word), or any other query that is not related to the expected input, the bot should prompt the user to provide the correct input. If the user is unable to provide the expected input, the bot should ask them to correct the query and try again. The bot should validate the user’s input and check if it’s correct. If the input is valid, it will proceed to the next node. If the input is invalid, the bot will delete the previous input value and redirect to the same entity node to collect a new input value.
As shown in the above screenshot, the entity node ‘ask_query’ will take the user’s query (which I want to validate). If the user provides input related to the expected query, the bot will ask, ‘Do you mean this?’ If the user selects the ‘Yes’ option, the directed flow will continue. If the user selects ‘No’, it will trigger the welcome task again.
Thanks in advance for help.
I think the best way to improve entry validation is to reconsider your overall approach to the conversation. The “how can I help you today?” message should capture the user’s initial utterance. The intent should be derived from the utterance (through training) and guide the conversation to a dialog for that specific intent. The platform has many ways to manage incorrect or inappropriate responses like the entries you have described, but using an entity node to capture the intent utterance will limit these capabilities. Try this method and see if you get better results.
Configure your welcome flow using a MESSAGE node as shown below:
Train your “guidance for claim form” dialog with “I’m looking for a possession form” and a few other utterance examples:
Use this flow structure and I think you’ll get much better results. Good luck!