Chamar LUIS do FormFlow em C #
Estou usando a estrutura de bot da Microsoft para criar um bot para questionar o usuário e entender a resposta. O usuário é questionado usando a API FormFlow na estrutura de bot e as respostas são recuperadas. Aqui está o código para o fluxo de formulário:
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();
}
}
O usuário pode entrar quando solicitado pelo nome:
meu nome é James Bond
Além disso, o nome pode ser de tamanho variável. Seria melhor chamar luis daqui e obter a entidade (nome) para a intenção. Atualmente, não estou ciente de como eu poderia chamar uma caixa de diálogo do luis no fluxo de formulário.