Skip to Content

How do I validate that a user enter the correct input in a requirement?

Hello

I ask for a requirement in a skill (an entity named #carateristica)and I save it in memory like caracteristica, but when a user enters some that is not a characteristic the skill doesn't validate the user's input and the skill fallback is triggered.

e.g

the user enters "new" as a characteristic and the respective action is executed: the message "you have choosed new"

but if the user enters something like " I don't know" the fallback skill is executed instead of the reply from the validator.

This is what I put on validator's reply.

Any idea why it isn't work?

input1.png (57.3 kB)
input2.png (58.3 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Aug 02, 2020 at 06:06 AM

    You can set up something like this:

    • You have an action called "GetUserFeedback" that asks for the feedback.
    • In that action, you set a variable "wait_feedback" to true, and the redirect (with "wait for user input" setting) to an action called "CheckAndSaveFeedback"
    • As Rohit said, you define a restricted entity called #characteristic with the valid values.
    • "SaveAndCheckFeedback" is triggered by "_memory.wait_feedback"
    • "SaveAndCheckFeedback" has an action that checks if your entity is present. If absent, you redirect to "GetUserFeedback".

    You could more simply create an intent, as you did, with a message if the entity is missing, but then they can write anything and trigger another intent. If that's OK, then that's OK.

    In my suggestion, you do have to make sure that "GetUserFeedback" is not triggered by an intent, because when the user enters the feedback, this could be anything and change the intent. Again, it depends what scenario you want -- do you just want to force the user to stay and enter the proper value or do you want the user to be able to enter a different intent and go elsewhere.


    redirect.png (59.6 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 31, 2020 at 08:03 AM

    Hi Yesid,

    The reason your validator is not working is because you have set two conditions which are same:

    "If #characteristic is missing" is same as "If #characteristic is absent". Therefore, your validator does not get triggered.

    Based on your validator message, I am assuming your entity has fixed values. If that is the case, then please set the entity type to restricted, instead of free and define all the relevant values.

    You can then update the characteristic is missing condition message with proper details and do away with the validator.

    Do let me know if that works out for you.

    Best Regards,

    Rohit

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Rohit

      Thank you for your prompt answer. Your solution is suitable, but I should consider that the user is not going always to enter a valid input, so what I want to do is to make a kind of loop to force the user enter a valid input, and I believed I could do it with the validator.

      P.S :Yes you're right, my entity has fixed values and I already have the entity #characteristic restricted.

      Best Regards.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.