public async Task SetCellStringValue(IDialogContext context, LuisResult result) { // Telemetry TelemetryHelper.TrackDialog(context, result, "Cells", "SetCellStringValue"); var cellAddress = LuisHelper.GetCellEntity(result.Entities); context.UserData.SetValue <string>("CellAddress", cellAddress); context.UserData.SetValue <ObjectType>("Type", ObjectType.Cell); context.UserData.SetValue <string>("Name", cellAddress); Value = LuisHelper.GetValue(result); string workbookId = String.Empty; context.UserData.TryGetValue <string>("WorkbookId", out workbookId); if (!(String.IsNullOrEmpty(workbookId))) { if (cellAddress != null) { await CellWorker.DoSetCellValue(context, Value); } else { await context.PostAsync($"You need to provide the name of a cell to set the value"); } context.Wait(MessageReceived); } else { context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_SetCellStringValue); } }
private async Task <DialogTurnResult> InitialStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var conversation = await conversationStateAccessor.GetAsync(stepContext.Context, () => new ConversationData()); var allergiesEntities = conversation.LuisResult.Entities.Where(x => x.Type.Equals(Luis.AllergyEntity)).ToList(); if (conversation.User != null) { conversation.User.Allergies = conversation.User.Allergies ?? new List <string>(); } else { conversation.User = new ServiceContracts.Models.User { Allergies = new List <string>() }; } if (allergiesEntities.Count() > 0) { var allergies = new List <string>(); foreach (var item in allergiesEntities) { allergies.Add(LuisHelper.GetNormalizedValueFromEntity(item)); } return(await stepContext.NextAsync(allergies)); } return(await stepContext.NextAsync()); }
public async Task LookupTableRow(IDialogContext context, LuisResult result) { // Telemetry TelemetryHelper.TrackDialog(context, result, "Tables", "LookupTableRow"); string workbookId = String.Empty; context.UserData.TryGetValue <string>("WorkbookId", out workbookId); var name = LuisHelper.GetNameEntity(result.Entities); if (name != null) { context.UserData.SetValue <string>("TableName", name); context.UserData.SetValue <ObjectType>("Type", ObjectType.Table); context.UserData.SetValue <string>("Name", name); } Value = (LuisHelper.GetValue(result))?.ToString(); if (!(String.IsNullOrEmpty(workbookId))) { await TablesWorker.DoLookupTableRow(context, (string)Value); context.Wait(MessageReceived); } else { context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_LookupTableRow); } }
private async Task <DialogTurnResult> ProcessInventoryNumberAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var userinput = stepContext.Result != null ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken) : new UserRequest(); var userInput = new UserRequest(); if (userinput.restart == true) { return(await stepContext.BeginDialogAsync(nameof(UserDialog), userinput, cancellationToken)); } else if (userinput.cancel == true) { return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Thank you for using the GLD Bot") }, cancellationToken)); } else if (stepContext.Result is int || stepContext.Result is string) { userInput.SKUNumber = stepContext.Result.ToString(); return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(" Invetory status of Sku# " + userInput.SKUNumber + ":" + "\nItem 1: 65 units\nLocation: Warehouse 1\nIf you would like to check inventory on another Sku# enter in the number? If not say \"no\"") }, cancellationToken)); } else { return(await stepContext.BeginDialogAsync(nameof(SKUDialog), userInput, cancellationToken)); } }
public static OrderForm ReadFromLuis(LuisResult luisResult) { var form = new OrderForm(); var foods = luisResult.Entities.Where(e => e.Type == "Food").ToList(); var quantities = luisResult.Entities.Where(e => e.Type == "builtin.number").ToList(); if (foods.Count > 0) { foreach (var item in foods) { form.Items.Add(LuisHelper.ResolveFood(item)); } } if (quantities.Count > 0) { foreach (var item in quantities) { form.Counts.Add(LuisHelper.ResolveQuantity(item)); } } return(form); }
private async Task <DialogTurnResult> InventoryTypeAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var userInput = stepContext.Result != null ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken) : new UserRequest(); if (userInput.isSKUNumber == true) { return(await stepContext.BeginDialogAsync(nameof(SKUDialog), userInput, cancellationToken)); } else if (userInput.ispurchaseOrderNumber == true) { return(await stepContext.BeginDialogAsync(nameof(poNumberDialog), userInput, cancellationToken)); } else if (userInput.cancel == true) { return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Thank you for using the GLD Bot") }, cancellationToken)); } else if (userInput.restart == true) { return(await stepContext.BeginDialogAsync(nameof(UserDialog), userInput, cancellationToken)); } else if (userInput.isjob == true) { return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Please visit our jobs website to learn more : https://www.jobs-ups.com") }, cancellationToken)); } else { return(null); } }
public async Task SelectWorksheet(IDialogContext context, LuisResult result) { // Telemetry TelemetryHelper.TrackDialog(context, result, "Worksheets", "SelectWorksheet"); string workbookId = String.Empty; context.UserData.TryGetValue <string>("WorkbookId", out workbookId); WorksheetName = LuisHelper.GetNameEntity(result.Entities); if (!(String.IsNullOrEmpty(workbookId))) { if (!(String.IsNullOrEmpty(WorksheetName))) { await WorksheetWorker.DoSelectWorksheetAsync(context, WorksheetName); context.Wait(MessageReceived); } else { // Call the SelectWorksheet Form SelectWorksheetForm.Worksheets = await WorksheetWorker.GetWorksheetNamesAsync(context, workbookId); context.Call <SelectWorksheetForm>( new FormDialog <SelectWorksheetForm>(new SelectWorksheetForm(), SelectWorksheetForm.BuildForm, FormOptions.PromptInStart), SelectWorksheet_FormComplete); } } else { context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_SelectWorksheet); } }
public async Task SetActiveCellValue(IDialogContext context, LuisResult result) { // Telemetry TelemetryHelper.TrackDialog(context, result, "Cells", "SetActiveCellValue"); ObjectType?type = null; context.UserData.TryGetValue <ObjectType?>("Type", out type); var name = string.Empty; context.UserData.TryGetValue <string>("Name", out name); Value = LuisHelper.GetValue(result); string workbookId = String.Empty; context.UserData.TryGetValue <string>("WorkbookId", out workbookId); if (!(String.IsNullOrEmpty(workbookId))) { await NamedItemsWorker.DoSetNamedItemValue(context, Value); context.Wait(MessageReceived); } else { context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_SetActiveCellValue); } }
public MainDialog(IConfiguration configuration, ILogger <MainDialog> logger) : base(nameof(MainDialog)) { Configuration = configuration; Logger = logger; luisHelper = new LuisHelper(configuration); AddDialog(new ChoicePrompt(nameof(ChoicePrompt))); AddDialog(new TextPrompt(nameof(TextPrompt))); AddDialog(new BusInformationDialog()); AddDialog(new TrackInfoDialog()); AddDialog(new WeatherInformationDialog()); AddDialog(new PhoneAdressDialog()); AddDialog(new ProfessorsDialog()); AddDialog(new WorkDialog()); AddDialog(new MatjeepchoochunDialog()); AddDialog(new NoticeDialog()); AddDialog(new TrackInfoCardDialog()); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { IntroStepAsync, ActStepAsync, })); InitialDialogId = nameof(WaterfallDialog); }
public async Task GetNamedItemValue(IDialogContext context, LuisResult result) { // Telemetry TelemetryHelper.TrackDialog(context, result, "NamedItems", "GetNamedItemValue"); var name = LuisHelper.GetNameEntity(result.Entities); if (!(String.IsNullOrEmpty(name))) { context.UserData.SetValue <string>("Name", name); context.UserData.SetValue <ObjectType>("Type", ObjectType.NamedItem); string workbookId = String.Empty; context.UserData.TryGetValue <string>("WorkbookId", out workbookId); if (!(String.IsNullOrEmpty(workbookId))) { await NamedItemsWorker.DoGetNamedItemValue(context); context.Wait(MessageReceived); } else { context.Call <bool>(new ConfirmOpenWorkbookDialog(), AfterConfirm_GetNamedItemValue); } } else { await context.PostAsync($"You need to provide a name to get the value"); context.Wait(MessageReceived); } }
private async Task <DialogTurnResult> ProcessConfirmation(WaterfallStepContext sc, CancellationToken cancellationToken) { var intent = await LuisHelper.GetIntent(_services, sc, cancellationToken); if (intent == GeneralLuis.Intent.Confirm) { // show entertainment DecrementedCountRefusal(sc); var card = await GetEntertainCard(sc); await sc.Context.SendActivityAsync(card, cancellationToken); IncrementShowing(sc); if (ShowingLimitReached(sc)) { return(await sc.EndDialogAsync()); } return(await sc.PromptAsync(DialogIds.EmptyPrompt, new PromptOptions { }, cancellationToken)); } IncrementCountRefusal(sc); if (RefusalLimitReached(sc)) { // talk to human await sc.EndDialogAsync(cancellationToken : cancellationToken); return(await sc.BeginDialogAsync(nameof(EscalateDialog))); } IncrementContentIndex(sc); // loop back return(await sc.ReplaceDialogAsync(nameof(EntertainDialog), GetOptionsFromStepContext(sc))); }
private async Task <DialogTurnResult> InitialStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var conversation = await conversationStateAccessor.GetAsync(stepContext.Context, () => new ConversationData()); var allergiesEntities = conversation.LuisResult.Entities.Where(x => x.Type.Equals(Luis.AllergyEntity)).ToList(); if (conversation.User != null) { if (allergiesEntities.Count() > 0) { var allergies = new List <string>(); foreach (var item in allergiesEntities) { allergies.Add(LuisHelper.GetNormalizedValueFromEntity(item)); } return(await stepContext.NextAsync(allergies)); } return(await stepContext.NextAsync()); } var message = messagesService.Get(MessagesKey.Key.RemoveAllergy_Error.ToString()).Value; await stepContext.Context.SendActivityAsync(message); return(await stepContext.EndDialogAsync()); }
private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var profile = await authHelper.GetAuthenticatedProfileAsync(stepContext.Context, cancellationToken); if (profile == null) { return(await stepContext.BeginDialogAsync(nameof(SignInDialog), cancellationToken : cancellationToken)); } // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.) var recognizerResult = await LuisHelper.ExecuteLuisQuery(TelemetryClient, configuration, this.logger, stepContext.Context, cancellationToken); // In this sample we only have a single Intent we are concerned with. However, typically a scenario // will have multiple different Intents each corresponding to starting a different child Dialog. var(intent, score) = recognizerResult.GetTopScoringIntent(); if (intent == "getvsoitem") { // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder. return(await stepContext.BeginDialogAsync(nameof(GetWorkItemDialog), recognizerResult, cancellationToken)); } else if (intent == "createvsoitem") { return(await stepContext.BeginDialogAsync(nameof(CreateWorkItemDialog), recognizerResult, cancellationToken)); } return(await stepContext.EndDialogAsync(null, cancellationToken)); }
private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var luisResult = await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken); switch (luisResult.Intent) { case "Book_flight": //We need to return flight details // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder. return(await stepContext.BeginDialogAsync(nameof(BookingDialog), luisResult, cancellationToken)); //return await stepContext.BeginDialogAsync(nameof(NewerDialog), luisResult, cancellationToken); case "AuthDialog_Intent": //Type something like "Oauth card" or "Auth Dialog intent" //Run the AuthBot Dialog return(await stepContext.BeginDialogAsync(nameof(AuthDialog), luisResult, cancellationToken)); case "APIDialog_Intent": //Type something like "Salesforce query" or "I need to check my quota" "I need to check my sales targets" //Run the AuthBot Dialog return(await stepContext.BeginDialogAsync(nameof(APIDialog), luisResult, cancellationToken)); case "None": case "Cancel": default: //Default to QnA await QnAHelper.ExecuteQnAQuery(Configuration, Logger, stepContext.Context, cancellationToken); return(await stepContext.BeginDialogAsync(nameof(MainDialog), null)); } }
private async Task <DialogTurnResult> InterruptAsync(DialogContext innerDc, CancellationToken cancellationToken = default(CancellationToken)) { if (innerDc.Context.Activity.Type != ActivityTypes.Message || innerDc.Context.Activity.Text == null || innerDc.Context.Activity.Speak == null) { return(null); } var text = innerDc.Context.Activity.Text.ToLowerInvariant(); var result = await LuisHelper.GetLuisResult(this.configuration, text).ConfigureAwait(false); if (result?.TopScoringIntent == null) { return(null); } switch (result.TopScoringIntent.Intent) { case "signout": await this.authHelper.SignOutAsync(innerDc.Context.Activity); await innerDc.Context.SendActivityAsync(MessageFactory.Text("You have been signed out."), cancellationToken); return(await innerDc.CancelAllDialogsAsync(cancellationToken)); case "Calendar.Cancel": await innerDc.Context.SendActivityAsync($"Cancelling", cancellationToken : cancellationToken); return(await innerDc.CancelAllDialogsAsync(cancellationToken)); } return(null); }
private async Task <DialogTurnResult> ProcessTrackingNumberAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var userinput = stepContext.Result != null ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken) : new UserRequest(); var userInput = new UserRequest(); if (userinput.restart == true) { return(await stepContext.BeginDialogAsync(nameof(UserDialog), userinput, cancellationToken)); } else if (userinput.cancel == true) { return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Thank you for using the GLD Bot") }, cancellationToken)); } else if (stepContext.Result is int || stepContext.Result is string) { userInput.UPSTrackingNumber = stepContext.Result.ToString(); return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(" Status of Order# " + userInput.UPSTrackingNumber + ":" + "\nShipping Address:\n12380 Morris Road\nAlpharetta GA 30004\nStatus: Delivered by end of day \nIf you would like to check on the status of another order please enter in the number? If not say \"no\"") }, cancellationToken)); } else { return(await stepContext.BeginDialogAsync(nameof(upsOrderNumberDialog), userInput, cancellationToken)); } }
private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.) var projectData = stepContext.Result != null ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken) : new ProjectData(); var temp = projectData.intentIdenified; var nameofstatus = ""; if (temp == "Get_Status") { nameofstatus = nameof(Getstatus); } else if (temp == "ReportStatus") { nameofstatus = nameof(SubmitStatusReqInput); } else if (temp == "ReportStatusWithInput") { nameofstatus = nameof(SubmitStatusNLP); } return(await stepContext.BeginDialogAsync(nameofstatus, projectData, cancellationToken)); }
private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.) var luisResult = stepContext.Result != null ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken) : new RecognizerResult(); detectedIntent = luisResult.GetTopScoringIntent().intent; if (detectedIntent == "Open_MS_Facilities_Ticket") { MSFacilitiesTicket ticketDetails = new MSFacilitiesTicket(); ticketDetails.IssueName = luisResult.Entities["IssueName"]?.FirstOrDefault()?["text"]?.ToString(); ticketDetails.Location = luisResult.Entities["Meeting_Room"]?.First()?.ToString(); return(await stepContext.BeginDialogAsync(nameof(MSFacilitiesDialog), ticketDetails, cancellationToken)); } if (detectedIntent == "Book_Doctor_Appointment") { DoctorAppointment doctorAppointment = new DoctorAppointment(); doctorAppointment.symptom = luisResult.Entities["Symptom"]?.FirstOrDefault()?.FirstOrDefault()?.ToString(); //doctorAppointment.timeslot = luisResult.Entities[""]?.First()?.ToString(); return(await stepContext.BeginDialogAsync(nameof(DoctorDialog), doctorAppointment, cancellationToken)); } // In this sample we only have a single Intent we are concerned with. However, typically a scenario // will have multiple different Intents each corresponding to starting a different child Dialog. // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder. return(await stepContext.BeginDialogAsync(nameof(BookingDialog), luisResult, cancellationToken)); }
//QnAMaker BotQNA; //private async Task<string> AccessQnAMaker(ITurnContext turnContext, CancellationToken cancellationToken, BotIntent intent) //{ // try // { // BotQNA = new QnAMaker(new QnAMakerEndpoint // { // EndpointKey = intent.Key, // Host = intent.HostName, // KnowledgeBaseId = intent.Id // }); // var results = await BotQNA.GetAnswersAsync(turnContext); // if (results.Any()) // { // return JsonConvert.SerializeObject(new IntentWithScore { Result = results.First().Answer, Score = results.First().Score.ToString() }); // //await turnContext.SendActivityAsync(MessageFactory.Text("QnA Maker Returned: " + results.First().Answer), cancellationToken); // } // else // { // return JsonConvert.SerializeObject(new IntentWithScore { Result = "Sorry, could not find an answer in the Q and A system.", Score = "0.00" }); // //await turnContext.SendActivityAsync(MessageFactory.Text("Sorry, could not find an answer in the Q and A system."), cancellationToken); // } // } // catch (Exception ex) // { // return JsonConvert.SerializeObject(new IntentWithScore { Result = ex.Message, Score = "-1.00" }); // //var x = ex.Message; // } //} private async Task <string> AccessLUIS(ITurnContext turnContext, CancellationToken cancellationToken, BotIntent intent) { var luisIntent = await LuisHelper.ExecuteLuisQuery(intent, null, turnContext, cancellationToken); return(JsonConvert.SerializeObject(luisIntent)); //await turnContext.SendActivityAsync(MessageFactory.Text($"Luis Intent: {luisIntent.Result} || Score: {luisIntent.Score}"), cancellationToken); //LogIntent(luisIntent); }
private async Task <DialogTurnResult> ProposeTips(WaterfallStepContext sc, CancellationToken cancellationToken) { var intent = await LuisHelper.GetIntent(_services, sc, cancellationToken); if (intent == GeneralLuis.Intent.Confirm) { return(await sc.BeginDialogAsync(nameof(EntertainDialog))); } return(await sc.EndDialogAsync()); }
private static string GetSubdialog(LuisResult luisResult) { var entity = luisResult.Entities.Where(x => x.Type.Equals(Luis.SubDialogs)).FirstOrDefault(); if (entity != null) { var entityNormalizeName = LuisHelper.GetNormalizedValueFromEntity(entity); return(entityNormalizeName + "Dialog"); } return(string.Empty); }
private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.) var bookingDetails = stepContext.Result != null ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken) : new BookingDetails(); // In this sample we only have a single Intent we are concerned with. However, typically a scenario // will have multiple different Intents each corresponding to starting a different child Dialog. // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder. return(await stepContext.BeginDialogAsync(nameof(BookingDialog), bookingDetails, cancellationToken)); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; var luidData = await LuisHelper.GetIntentAndEntitiesFromLUIS(message.Text); var dialog = _dialogFactory.Create <RootDialogFactory>().GetDialog(context, luidData); if ((luidData.TopScoringIntent.Intent != LuisIntent.Greetings) && (dialog.GetType().ToString() == "GreetingDialog")) { await context.PostAsync(MessagesResource.CourtesyError); } context.Call(dialog, Callback); }
private async Task <DialogTurnResult> MileageStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.) var distanceInfo = stepContext.Result != null ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken) : new DistanceInfo(); // In this sample we only have a single Intent we are concerned with. However, typically a scenario // will have multiple different Intents each corresponding to starting a different child Dialog. // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder. return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(distanceInfo.Distance.ToString()) }, cancellationToken)); }
//查询Luis,返回结果 private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { //await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("示例:\"北京今天天气如何\"") }, cancellationToken); Console.WriteLine("******************************"); Console.WriteLine(stepContext.Context); var QueryDetails = await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken); /* * var QueryDetails = stepContext.Result != null * ? * await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken) * : * new QueryDetails(); */ return(await stepContext.BeginDialogAsync(nameof(DetailQueryDialog), QueryDetails, cancellationToken)); }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task OpenWorkbook(IDialogContext context, LuisResult result) #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { // Telemetry TelemetryHelper.TrackDialog(context, result, "Workbooks", "OpenWorkbook"); // Create the Open workbook form and extract the workbook name from the query var form = new OpenWorkbookForm(); form.WorkbookName = (string)(LuisHelper.GetValue(result)); // Call the OpenWorkbook Form context.Call <OpenWorkbookForm>( new FormDialog <OpenWorkbookForm>(form, OpenWorkbookForm.BuildForm, FormOptions.PromptInStart), OpenWorkbookFormComplete); }
public async Task GetTask(IDialogContext context, IAwaitable <IMessageActivity> result) { var userResponse = await result; var luisResult = await LuisHelper.GetIntentAndEntitiesFromLUIS(userResponse.Text); switch (luisResult.TopScoringIntent.Intent) { case LuisIntent.Yes: { await context.PostAsync(MessagesResource.AddOtherProducts); context.Call(_dialogFactory.Create <GetProductsByUserTask>(), Callback); break; } case LuisIntent.No: { context.Call(_dialogFactory.Create <AskIfWantSuggestionProductsTask>(), Callback); break; } default: { var handler = new HandleUserIncorrectInput(context); if (handler.CheckCounterErrors()) { await handler.UserErrorLimitExceeded(); context.Call(_dialogFactory.Create <GreetingDialog>(), Callback); } else { await context.PostAsync(MessagesResource.CourtesyChooseError); var sender = new SendCorrectYesOrNoCard(context); await sender.Send(MessagesResource.AskIfWantAddProduct); context.Wait(GetTask); } break; } } }
private async Task<DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { // Chama o LUIS e reúne todas as possíveis intenções. (Observe que o TurnContext tem a resposta para o prompt). var LUISResponse = stepContext.Result != null ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken) : new LUISResponse(); if (LUISResponse.Intencao == Intencao.conversa_saudacao) return await stepContext.BeginDialogAsync(nameof(SaudacaoDialog), cancellationToken); else if (LUISResponse.Intencao == Intencao.conversa_sobre) return await stepContext.BeginDialogAsync(nameof(SobreDialog), cancellationToken); else if (LUISResponse.Intencao == Intencao.moeda_cotacao) return await stepContext.BeginDialogAsync(nameof(CotacaoDialog), LUISResponse, cancellationToken); else if (LUISResponse.Intencao == Intencao.moeda_listagem) return await stepContext.BeginDialogAsync(nameof(CotacaoListagemDialog), LUISResponse, cancellationToken); return await stepContext.BeginDialogAsync(nameof(NaoReconhecidoDialog), cancellationToken); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; //var city = activity.Text ?? string.Empty; var query = activity.Text ?? string.Empty; var luisInformaion = await LuisHelper.ParseTextAsync(query); var city = GetCityName(luisInformaion); var weatherInforamion = await OpenWeatherAPIHelper.GetWeatherDataAsync(city); var weatherstring = GetWeather(weatherInforamion); await context.PostAsync(weatherstring); context.Wait(MessageReceivedAsync); }
private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { if (!(stepContext.Context.Activity.Text.Trim().ToUpper().Contains("KB0"))) { if (stepContext.Result != null) { if (stepContext.Result.Equals(true)) { // var bookingDetails = (BookingDetails)stepContext.Options; //return await stepContext.EndDialogAsync(bookingDetails, cancellationToken); await stepContext.Context.SendActivityAsync( MessageFactory.Text("Please enter any other query."), cancellationToken); // return await stepContext.EndDialogAsync(null, cancellationToken); return(await stepContext.NextAsync(null, cancellationToken)); } else if (stepContext.Result.Equals(false)) { var bookingDetails = stepContext.Result != null ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, /* Recognizerresult,*/ cancellationToken) : new BookingDetails(); //await stepContext.Context.SendActivityAsync( // MessageFactory.Text("Incident Created..!"), cancellationToken); //return await stepContext.EndDialogAsync(null, cancellationToken); return(await stepContext.BeginDialogAsync(nameof(BookingDialog), bookingDetails, cancellationToken)); } else { return(await stepContext.EndDialogAsync(null, cancellationToken)); } } else { return(await stepContext.EndDialogAsync(null, cancellationToken)); } } return(await stepContext.EndDialogAsync(null, cancellationToken)); }