private async Task <DialogTurnResult> GreetingStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var luisResult = await _luisRecognizer.RecognizeAsync <MathBot>(stepContext.Context, cancellationToken); switch (luisResult.TopIntent().intent) { case MathBot.Intent.Name: string name = luisResult.NameEntity; var getGreetingMessageText = $"Hello, {name}!"; var getGreetingMessage = MessageFactory.Text(getGreetingMessageText, getGreetingMessageText, InputHints.IgnoringInput); await stepContext.Context.SendActivityAsync(getGreetingMessage, cancellationToken); break; default: // Catch all for unhandled intents var didntUnderstandMessageText = $"Sorry, I didn't get that. Please try asking in a different way (intent was {luisResult.TopIntent().intent})"; var didntUnderstandMessage = MessageFactory.Text(didntUnderstandMessageText, didntUnderstandMessageText, InputHints.IgnoringInput); await stepContext.Context.SendActivityAsync(didntUnderstandMessage, cancellationToken); break; } var attachments = new List <Attachment>(); var messageText = stepContext.Options?.ToString() ?? $"What type of challenge do you want to play? These are the options: "; var reply = MessageFactory.Attachment(attachments); reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; reply.Attachments.Add(Cards.GetThumbnailCard1().ToAttachment()); reply.Attachments.Add(Cards.GetThumbnailCard2().ToAttachment()); reply.Attachments.Add(Cards.GetThumbnailCard3().ToAttachment()); var promptMessage = MessageFactory.Text(messageText, messageText, InputHints.ExpectingInput); await stepContext.Context.SendActivityAsync(reply, cancellationToken); return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = promptMessage }, cancellationToken)); }
private async Task <DialogTurnResult> AnswerAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var luisResult = await _luisRecognizer.RecognizeAsync <MathBot>(stepContext.Context, cancellationToken); switch (luisResult.TopIntent().intent) { case MathBot.Intent.Answer: questionNr++; string answer = luisResult.NumberEntity; var feedbackMessageText = ""; if (answer.Equals(currentAnswer.ToString())) { feedbackMessageText = $"{answer} is correct!, excellent"; points++; } else { lives_remaining--; feedbackMessageText = $"{answer} is wrong but keep trying, you got this! Remember, you have {lives_remaining} lives left!"; if (lives_remaining < 1) { return(await stepContext.NextAsync(1, cancellationToken)); } } var getGreetingMessage = MessageFactory.Text(feedbackMessageText, feedbackMessageText, InputHints.IgnoringInput); await stepContext.Context.SendActivityAsync(getGreetingMessage, cancellationToken); break; default: // Catch all for unhandled intents var didntUnderstandMessageText = $"Sorry, I didn't get that. Please try asking in a different way (intent was {luisResult.TopIntent().intent})"; var didntUnderstandMessage = MessageFactory.Text(didntUnderstandMessageText, didntUnderstandMessageText, InputHints.IgnoringInput); await stepContext.Context.SendActivityAsync(didntUnderstandMessage, cancellationToken); break; } return(await stepContext.NextAsync(null, cancellationToken)); }