How do I validate user input?

(Nick) #1

Hi fellow users, I’m wondering if it’s possible to validate user’s input? This is what I intend to achieve: a user would be asked to enter a verification code when using the bot. There is a stored string with the code in the Flow Xo and this string will be compared with the user’s input. If the user input matches the string then the bot will ask the next question, else the bot would respond with an error stating “Wrong code”. Any kind soul willing to help me out? Your response will be appreciated. Thanks.

(John Jackson) #2

This is really easy to do! Follow these steps:

  1. For your first action (after the trigger) use Bot > Ask a Question to ask for your verification code.
  2. Next, add a Bot > Send a Message action with the text “Wrong code”. When you get to the filter step, find the Answer output you previous action, and filter on does not equal your verification code. Tick the box to Also stop rest of flow if conditions are met. This means that if the code is wrong, this action and only this action will run, and tell the user that it’s the wrong code.
  3. Put the actions you want to run for a correct code after this. You can add as many as you need.

Hope that’s helpful! Good luck with it. :grin:

(Nick) #3

Oh I see, I tried the solution out and it worked. Thanks for the fast response! Appreciate it​:blush::+1: