private async Task HazardousIncidentFormComplete(IDialogContext context, IAwaitable <HazardousIncident> result) { HazardousIncident info = null; try { info = await result; } catch (OperationCanceledException) { await context.PostAsync("You canceled the form!"); return; } if (info != null) { await context.PostAsync("Your result: " + info.ToString()); } else { await context.PostAsync("Form returned empty response!"); } context.Wait(MessageReceived); }
public async Task HazardousIncidentsIntent(IDialogContext context, LuisResult result) { await context.PostAsync($"You have reached {result.Intents[0].Intent}. You said: {result.Query}"); var entities = new List <EntityRecommendation>(result.Entities); string location = ""; string timePeriod = ""; foreach (EntityRecommendation entity in result.Entities) { await context.PostAsync($"Entities found {entity.Entity} of type {entity.Type}"); } HazardousIncident form; if (!location.Equals("") && !timePeriod.Equals("")) { form = new HazardousIncident(location, timePeriod); } else if (location.Equals("") && !timePeriod.Equals("")) { form = new HazardousIncident(timePeriod); } else { form = new HazardousIncident(); } var hazardousInfoForm = new FormDialog <HazardousIncident>(form, HazardousIncident.BuildEnquiryForm, FormOptions.PromptInStart, entities); context.Call <HazardousIncident>(hazardousInfoForm, HazardousIncidentFormComplete); }