I am using the Microsoft bot framework to create a bot for questioning the user and then understanding the answer. The user is questioned using the FormFlow API in bot framework and answers are retrieved. Here is the code for the formflow:
public enum Genders { none, Male, Female, Other};
[Serializable]
public class RegisterPatientForm
{
[Prompt("What is the patient`s name?")]
public string person_name;
[Prompt("What is the patients gender? {||}")]
public Genders gender;
[Prompt("What is the patients phone number?")]
[Pattern(@"(<Undefined control sequence>\d)?\s*\d{3}(-|\s*)\d{4}")]
public string phone_number;
[Prompt("What is the patients Date of birth?")]
public DateTime DOB;
[Prompt("What is the patients CNIC number?")]
public string cnic;
public static IForm<RegisterPatientForm> BuildForm()
{
OnCompletionAsyncDelegate<RegisterPatientForm> processHotelsSearch = async (context, state) =>
{
await context.PostAsync($"Patient {state.person_name} registered");
};
return new FormBuilder<RegisterPatientForm>()
.Field(nameof(person_name),
validate: async (state, value) =>
{
//code here for calling luis
})
.Field(nameof(gender))
.Field(nameof(phone_number))
.Field(nameof(DOB))
.Field(nameof(cnic))
.OnCompletion(processHotelsSearch)
.Build();
}
}
The user may enter when asked for name :
my name is James Bond
Also the name could be of variable length. I would be better to call luis from here and get the entity(name) for the intent. I am currently not aware on how could i call a luis dialog from the formflow.
You can use the API method of LUIS, instead of the dialog method.
Your code would be - RegisterPatientForm Class :
Here
GetIntentAndEntitiesFromLUIS
method does the querying to LUIS using the endpoint exposed by your Luis app. Add the endpoint to your Web.config with keyLuisModelEndpoint
Your web.config would look like this
I have created a LUISOutput class to deserialize the response:
Emulator Response
In this situation, it may be best to call a luis intent outside of formflow. The functionality you are looking for does not exactly exist. You could call a "Name" intent then call you form like this: