Skip to content

Botframework .NET example of making a LUIS call inside a form flow

License

Notifications You must be signed in to change notification settings

Kumar-Ashwin-Hubert/LuisInsideFormFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LuisInsideFormFlowBot

Emulator Example

Once the user has typed in the name of the person or a statement describing the name of the person in the form flow, it will be sent to LUIS API and later the name entity returned from LUIS API, will be set in the form value :

return new FormBuilder<RegisterPatientForm>()
    .Field(nameof(person_name),
        validate: async (state, response) =>
        {
            var result = new ValidateResult { IsValid = true, Value = response };
            
            //Query LUIS and get the response
            LUISOutput LuisOutput = await GetIntentAndEntitiesFromLUIS((string)response);

            //Now you have the intents and entities in LuisOutput object
            //See if your entity is present in the intent and then retrieve the value
            if (LuisOutput != null && Array.Find(LuisOutput.intents, intent => intent.Intent == "GetName") != null)
            {
                LUISEntity LuisEntity = Array.Find(LuisOutput.entities, element => element.Type == "name");

                if (LuisEntity != null)
                {
                    //Store the found response in resut
                    result.Value = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(LuisEntity.Entity);
                }
                else
                {
                    //Name not found in the response
                    result.IsValid = false;
                }
            }
            else if(LuisOutput != null && Array.Find(LuisOutput.intents, intent => intent.Intent == "None") != null)
            {
                //In case of none intent assume that the user entered a name
                result.Value = LuisOutput.query;
            }
            else
            {
                result.IsValid = false;
            }
            return result;
        })
    .Field(nameof(gender))
    .Field(nameof(phone_number))
    .Field(nameof(DOB))
    .Field(nameof(cnic))
    .OnCompletion(processHotelsSearch)
    .Build();

About

Botframework .NET example of making a LUIS call inside a form flow

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published