private static async Task <DialogTurnResult> WaterfallStep3(DialogContext dc, WaterfallStepContext stepContext, CancellationToken cancellationToken)
 {
     if (stepContext.Values != null)
     {
         var numberResult = (int)stepContext.Result;
         await dc.Context.SendActivityAsync(MessageFactory.Text($"Got '{numberResult}'."), cancellationToken);
     }
     return(await dc.BeginAsync("TestComponentDialog", null, cancellationToken));
 }
Beispiel #2
0
 private static async Task <DialogTurnResult> WaterfallStep3(DialogContext dc, WaterfallStepContext stepContext)
 {
     if (stepContext.Values != null)
     {
         var numberResult = (int)stepContext.Result;
         await dc.Context.SendActivityAsync($"Got '{numberResult}'.");
     }
     return(await dc.BeginAsync("TestComponentDialog"));
 }
        private static async Task <DialogTurnResult> Waterfall3_Step2(DialogContext dc, WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            await dc.Context.SendActivityAsync(MessageFactory.Text("step2"), cancellationToken);

            return(await dc.BeginAsync("test-waterfall-c", null, cancellationToken));
        }
Beispiel #4
0
        private static async Task <DialogTurnResult> Waterfall3_Step2(DialogContext dc, WaterfallStepContext stepContext)
        {
            await dc.Context.SendActivityAsync("step2");

            return(await dc.BeginAsync("test-waterfall-c"));
        }
        private static async Task Waterfall3_Step2(DialogContext dc, object args, SkipStepFunction next)
        {
            await dc.Context.SendActivityAsync("step2");

            await dc.BeginAsync("test-waterfall-c");
        }
        public async Task OnTurnAsync(ITurnContext turnContext,
                                      CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                DialogContext dc = null;

                switch (turnContext.Activity.Type)
                {
                case ActivityTypes.Message:

                    switch (turnContext.Activity.Text.ToLowerInvariant())
                    {
                    case "signout":
                    case "logout":
                    case "signoff":
                    case "logoff":
                        var botAdapter = (BotFrameworkAdapter)turnContext.Adapter;
                        await botAdapter.SignOutUserAsync(turnContext, ConnectionSettingName,
                                                          CancellationToken.None);

                        await turnContext.SendActivityAsync("You are now signed out.");

                        break;

                    case "help":
                        await turnContext.SendActivityAsync(HelpText);

                        break;

                    default:
                        dc = await _dialogs.CreateContextAsync(turnContext);

                        await dc.ContinueAsync();

                        if (!turnContext.Responded)
                        {
                            await dc.BeginAsync("displayToken");
                        }
                        break;
                    }

                    break;

                case ActivityTypes.Event:
                case ActivityTypes.Invoke:
                    // This handles the MS Teams invoke activity sent when magic code is not used
                    //See: https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/authentication/auth-oauth-card#getting-started-with-oauthcard-in-teams
                    //Manifest Schema Here: https://docs.microsoft.com/en-us/microsoftteams/platform/resources/schema/manifest-schema
                    dc = await _dialogs.CreateContextAsync(turnContext);

                    await dc.ContinueAsync();

                    if (!turnContext.Responded)
                    {
                        await dc.BeginAsync("displayToken");
                    }
                    break;

                case ActivityTypes.ConversationUpdate:
                    var newUserName = turnContext.Activity.MembersAdded.FirstOrDefault()?.Name;
                    if (!string.Equals("Bot", newUserName))
                    {
                        var reply = turnContext.Activity.CreateReply();
                        reply.Text        = HelpText;
                        reply.Attachments = new List <Attachment> {
                            GetHeroCard(newUserName).ToAttachment()
                        };
                        await turnContext.SendActivityAsync(reply);
                    }

                    break;
                }
            }
            catch (Exception e)
            {
                await turnContext.SendActivityAsync($"Exception: {e.Message}");
            }
        }