protected override async Task OnMembersAddedAsync(IList <ChannelAccount> membersAdded, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
        {
            foreach (var member in membersAdded)
            {
                // Greet anyone that was not the target (recipient) of this message.
                // To learn more about Adaptive Cards, see https://aka.ms/msbot-adaptivecards for more details.
                if (member.Id != turnContext.Activity.Recipient.Id)
                {
                    var welcomeCard = AdaptiveCard.CreateAttachment("SickBot.Cards.WelcomeCard_de.json");
                    var response    = MessageFactory.Attachment(welcomeCard);
                    await turnContext.SendActivityAsync(response, cancellationToken);

                    await Dialog.RunAsync(turnContext, ConversationState.CreateProperty <DialogState>("DialogState"), cancellationToken);
                }
            }
        }
예제 #2
0
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS and gather any potential notification of illness details. (Note the TurnContext has the response to the prompt.)
            var luisResult = await m_LuisRecognizer.RecognizeAsync <Luis.SickBot>(stepContext.Context, cancellationToken);

            switch (luisResult.TopIntent().intent)
            {
            case Luis.SickBot.Intent.NotificationOfIllness:
                // Initialize NotificationOfIllnessDetails with any entities we may have found in the response.
                var userData = await m_UserStateAccessors.GetAsync(stepContext.Context, () => new UserData(), cancellationToken);

                var notificationOfIllnessDetails = new NotificationOfIllnessDetails
                {
                    Text          = luisResult.Text,
                    SickUntil     = luisResult.SickUntilTimex,
                    TokenResponse = userData.TokenResponse
                };

                // Run the Dialog giving it whatever details we have from the LUIS call, it will fill out the remainder.
                return(await stepContext.BeginDialogAsync(nameof(NotificationOfIllnessDialog), notificationOfIllnessDetails, cancellationToken));

            case Luis.SickBot.Intent.Utilities_Help:
                var welcomeCard = AdaptiveCard.CreateAttachment("SickBot.Cards.HelpCard_de.json");
                var response    = MessageFactory.Attachment(welcomeCard);
                await stepContext.Context.SendActivityAsync(response, cancellationToken);

                break;

            case Luis.SickBot.Intent.Utilities_Stop:
                var cancelMsgText = "Ich breche jetzt ab.";
                var cancelMessage = MessageFactory.Text(cancelMsgText, cancelMsgText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(cancelMessage, cancellationToken);

                return(await stepContext.CancelAllDialogsAsync(cancellationToken));

            default:
                // Catch all for unhandled intents
                var notUnderstandMessageText = $"Sorry, I didn't get that. Please try asking in a different way (intent was {luisResult.TopIntent().intent})";
                var notUnderstandMessage     = MessageFactory.Text(notUnderstandMessageText, notUnderstandMessageText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(notUnderstandMessage, cancellationToken);

                break;
            }

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