Yes, it is possible.
When constructing your Formflow, for all properties of your entity, configure the Field() method of formflow with the validated parameter and call a method that tries to extract all possible entities from LUIS and save in the instance that Formflow is filling.
.Field(nameof(NomePropriedade), validate: async (state, value) => await ExtractEntity((state as NomeClasse), value, "nomeEntidadeLuisCorrespondenteAoCampoDaVez"))
applying would look like this:
.Field(nameof(DataNascimento), validate: async (state, value) => await ExtractEntity((state as Cliente), value, "data_nascimento"))
so in every question that Formflow makes you can intercept and extract the entities of luis and send to state.
The Extractentity method would look like this:
protected static async Task<ValidateResult> ExtractEntity(Cliente state, object value, string entityName, Func<ValidateResult, Task<ValidateResult>> next = null)
{
INLPService service = NLPServiceFactory.Create("NomeServicoLuis");
var nlpresult = await service.QueryAsync(value.ToString());
var entity = nlpresult.QueryEntity(entityName);
var result = new ValidateResult { IsValid = true, Value = string.IsNullOrEmpty(entity) ? value : entity };
var nomeEntity = nlpresult.QueryEntity("nome");
var dataNascimentoEntity = nlpresult.QueryEntity("data_nascimento");
state.Nome = CoalesceEntityValue(nomeEntity, entityName, "nome", value.ToString(), state.Nome);
state.DataNascimento = CoalesceEntityValue(dataNascimentoEntity, entityName, "data_nascimento", value.ToString(), state.DataNascimento);
if (next != null)
return await next(result);
else
return result;
}
And finally the Coalesceentityvalue method decides which value to assign in the property, the extracted value of luis, which user typed the current value.
private static string CoalesceEntityValue(string extractedEntityValue, string extractedEntityName, string entityName, string rawEntityValue, string currentValue)
{
if (!string.IsNullOrEmpty(extractedEntityValue))
{
return extractedEntityValue;
}
else if (!string.IsNullOrEmpty(rawEntityValue) && entityName == extractedEntityName)
{
return rawEntityValue;
}
else
{
return currentValue;
}
}
Any doubt I’m available.