コード例 #1
0
ファイル: ReportDialog.cs プロジェクト: Check-den-Fakt/Bot
        private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (stepContext.Result != null)
            {
                Models.ReportDetails reportDetails = new Models.ReportDetails();
                reportDetails.Text = stepContext.Result.ToString();

                return(await stepContext.EndDialogAsync(reportDetails, cancellationToken));
            }

            return(await stepContext.EndDialogAsync(null, cancellationToken));
        }
コード例 #2
0
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (!luisRecognizer.IsConfigured)
            {
                // LUIS is not configured, we just run the BookingDialog path with an empty BookingDetailsInstance.
                return(await stepContext.BeginDialogAsync(nameof(CheckFactDialog), new Models.FactDetails(), cancellationToken).ConfigureAwait(false));
            }

            // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
            var luisResult = await luisRecognizer.RecognizeAsync <ChatIntents>(stepContext.Context, cancellationToken).ConfigureAwait(false);

            switch (luisResult.TopIntent().intent)
            {
            case ChatIntents.Intent.Help:

                string helpText    = $"Aktuell kannst du bei uns Fakten prüfen und melden. Gib hierzu einfach zum Beispiel \"prüfe meinen fakt ein\"";
                var    helpMessage = MessageFactory.Text(helpText, helpText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(helpMessage, cancellationToken).ConfigureAwait(false);

                break;

            case ChatIntents.Intent.Check:

                var factDetails = new Models.FactDetails()
                {
                };

                return(await stepContext.BeginDialogAsync(nameof(CheckFactDialog), factDetails, cancellationToken).ConfigureAwait(false));

            case ChatIntents.Intent.Report:
                var reportDetails = new Models.ReportDetails();

                return(await stepContext.BeginDialogAsync(nameof(ReportDialog), reportDetails, cancellationToken).ConfigureAwait(false));

            case ChatIntents.Intent.Welcome:
                string welcomeText = $"Hallo, willkommen bei Check-den-Fakt.de";

                var welcomeMessage = MessageFactory.Text(welcomeText, welcomeText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(welcomeMessage, cancellationToken).ConfigureAwait(false);

                break;

            case ChatIntents.Intent.FAQ:

                var qnaDetails = new Models.QnADetails()
                {
                };

                return(await stepContext.BeginDialogAsync(nameof(QnADialog), qnaDetails, cancellationToken).ConfigureAwait(false));

            default:
                // Catch all for unhandled intents
                var didntUnderstandMessageText = $"Sorry, ich habe dich nicht verstanden :(";
                var didntUnderstandMessage     = MessageFactory.Text(didntUnderstandMessageText, didntUnderstandMessageText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(didntUnderstandMessage, cancellationToken).ConfigureAwait(false);

                break;
            }

            return(await stepContext.NextAsync(null, cancellationToken).ConfigureAwait(false));
        }