private async Task <DialogTurnResult> AskforPhotoStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var userData = await BotStateAccessor.GetAsync(stepContext.Context, () => new UserData(), cancellationToken); // Get the text from the activity to use to show the correct card var text = stepContext.Context.Activity.Text.ToLowerInvariant(); var isPositiveFeedback = await TextAnalyticsService.GetTextSentimentAsync(text) > 0.5; userData.ProductWasFound = isPositiveFeedback; if (isPositiveFeedback) { // We go directly to the next step as we don't need any input from the user return(await stepContext.NextAsync()); } else { return(await stepContext.PromptAsync( AskForImage, new PromptOptions { Prompt = MessageFactory.Text("Do you have a photo of a watch you like? In order to help you we will need an image of a simillar watch to search."), RetryPrompt = MessageFactory.Text("I didn't find any watch on the provided image. Please provide an image with a similar watch you are looking for to continue"), }, cancellationToken)); } }
private async Task <DialogTurnResult> CheckStoreCalendarStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var userData = await UserStateAccessor.GetAsync(stepContext.Context, () => new Models.UserData(), cancellationToken); var textResult = ((string)stepContext.Result).ToLowerInvariant(); var isPositiveFeedback = await _textAnalyticsService.GetTextSentimentAsync(textResult) > 0.5; userData.IsStoreSelectionOk = isPositiveFeedback; if (isPositiveFeedback) { await stepContext.Context.SendActivityAsync("Checking calendars...", cancellationToken : cancellationToken); var recommendation = await GetAppointmentScheduleRecommendationAsync(_origin, _destination); var reply = stepContext.Context.Activity.CreateReply($"I have team members available during the following time slots. {recommendation}"); var actions = new[] { new CardAction() { Title = "8:00 a.m. - 9:00 a.m.", Type = ActionTypes.ImBack, Value = "8:00 a.m. - 9:00 a.m." }, new CardAction() { Title = "9:00 a.m. - 10:00 a.m.", Type = ActionTypes.ImBack, Value = "9:00 a.m. - 10:00 a.m." }, new CardAction() { Title = "10:00 a.m. - 11:00 a.m.", Type = ActionTypes.ImBack, Value = "10:00 a.m. - 11:00 a.m." }, new CardAction() { Title = "11:00 a.m. - 12:00 p.m.", Type = ActionTypes.ImBack, Value = "11:00 a.m. - 12:00 p.m." }, new CardAction() { Title = "12:00 p.m. - 1:00 p.m.", Type = ActionTypes.ImBack, Value = "12:00 p.m. - 1:00 p.m." }, new CardAction() { Title = "1:00 p.m. - 2:00 a.m.", Type = ActionTypes.ImBack, Value = "1:00 p.m. - 2:00 a.m." }, }; var cards = actions .Select(x => new HeroCard { Buttons = new List <CardAction> { x }, }.ToAttachment()) .ToList(); reply.AttachmentLayout = AttachmentLayoutTypes.List; reply.Attachments = cards; // Create options for the prompt var options = new PromptOptions() { Prompt = reply, }; return(await stepContext.PromptAsync(SelectStoreSchedule, options, cancellationToken)); } else { return(await SaveSelfieStepAsync(stepContext, cancellationToken)); } }