Checking User inputs on formflow

129 views Asked by At

Hi guys im using formflow, everything is working smoothly, i just have some small details that i need to fix.

  • Is there a way for me to check via regex the user inputs during the formflow? i need to check if the user inputs a valid name, email etc.
  • Can i change the confirmation before profile complete to a yes or no button instead of typing yes or no or y or n?

Below is the code

[Serializable]
public class ProfileForm
{
    [Prompt("What is your first name? {||}")]
    public string FirstName;
    [Prompt("What is your last name? {||}")]
    public string LastName;
    [Prompt("What is your email? {||}")]
    public string Email;

    public static IForm<ProfileForm> BuildForm()
    {
        return new FormBuilder<ProfileForm>()
                .Message("Welcome to the profile bot!")
                .OnCompletion(async (context, profileForm) =>
                {
                    // Tell the user that the form is complete
                    await context.PostAsync("Your profile is complete.");
                })
                .Build();
    }
}
1

There are 1 answers

0
Witted On BEST ANSWER

So this hasn't been answered in a month so I hope by now you have found the answer yourself. If not, here is an easy way:

[Pattern(@"Put pattern here")]  
    public string Email; 

This way checks the string on input and will automatically request another try if it is incorrectly entered.

There are commonly used patterns for most of what you are looking for online. This post and this one are good at showcasing some of the ways to customise FormFlows. Hope this helps.

Edit. Sorry missed the second part of the question. To add a simple confirm button add this to your formflow:

.Confirm("Thanks, please can you confirm everything below is correct {*} {||}")

The "{*}" will show all the fields and the users response and the "{||}" will show the Yes/No buttons that you want.