Articles → MICROSOFT BOT FRAMEWORK → Set The Order Of Questions In Formflow In Microsoft Bot Framework
Set The Order Of Questions In Formflow In Microsoft Bot Framework
public int Age;
public string Name;
Click to Enlarge
public static IForm < FormFlowDemo > GetForm() {
return new FormBuilder<FormFlowDemo>()
.Message("Welcome to support chat system. Please enter the following information to serve you better")
.Field(nameof(Name))
.Field(nameof(Age)).Build();
}
Click to Enlarge
Complete Code
using Microsoft.Bot.Builder.FormFlow;
using System;
namespace Bot_Application1.Dialogs {
[Serializable]
public class FormFlowDemo {
public int Age;
public string Name;
public static IForm < FormFlowDemo > GetForm() {
return new FormBuilder < FormFlowDemo > ().Message("Welcome to support chat system. Please enter the following information to serve you better").Field(nameof(Name)).Field(nameof(Age)).Build();
}
}
}
Validate Data Inside The Field Function
public static IForm <FormFlowDemo> GetForm() {
return new FormBuilder < FormFlowDemo>()
.Message("Welcome to support chat system. Please enter the following information to open bank account").Field(nameof(Name))
.Field(nameof(Age), validate: async(state, response) =>{
var validation = new ValidateResult {
IsValid = true,
Value = response
};
if (Convert.ToInt32(response) < 18) {
validation.IsValid = false;
validation.Feedback = "You are eligible to open bank account as you are below 18 years of age";
}
return validation;
}).Build();
}
Click to Enlarge