0

I have 4 Dialogs in my Project the First one is a

RootDialog

with some enum. This is my root dialog so If user select the first option then I want to send him to the

CreateContact

Dialog which I added below and if user selcts

GetContact

or

SendMail

then I will send him to the appropriate Dialog but I am unable to call anothe form dialog on completion or selection of first Dialog.

 [Serializable]
        public enum RootOptions
        {
            CreateContact = 1, GetContact = 2, SendMail
        };

 [Serializable]
        public class RootForm
        {
            public RootOptions? Option;
            public static IForm<RootForm> BuildForm()
            {
                return new FormBuilder<RootForm>()
                        .Message("Welcome to TEST BOT!")
                        .OnCompletion(async (context, rootoption) =>
                        {
                            switch(rootoption.Option.Value.ToString()) "")
                            {
                                case "CreateContact":
                                //How to call Contact Dialog
                                break;
                                case "GetContact":
                                //Call Get Contact Dialog
                                break;
                                case "SendMail":
                                //Call Send Mail Dialog
                                break;
                            }
                        })
                        .Build();
            }
        }

Create Contact Dialog

[Serializable]
        public class ContactForm
        {
            [Prompt("What is the name? {||}")]
            public string Name;
            [Prompt("What is the Mobile No? {||}")]
            public string Mobile;
            [Prompt("What is the Email? {||}")]
            public string Email;
            public static IForm<ContactForm> BuildForm()
            {
                return new FormBuilder<ContactForm>()
                        .Message("Let's create a contact")
                        .OnCompletion(async (context, profileForm) =>
                        {
                        await context.PostAsync("Your contact has been created.");
                        })
                        .Build();
            }
        }

Send Mail Dialog

[Serializable]
        public class MailForm
        {
            [Prompt("What is the Email Id? {||}")]
            public string Email;
            [Prompt("What is the Subject? {||}")]
            public string subject;
            [Prompt("What is the Message? {||}")]
            public string Message;
            public static IForm<MailForm> BuildForm()
            {
                return new FormBuilder<MailForm>()
                        .Message("Let's Send a Mail")
                        .OnCompletion(async (context, mailForm) =>
                        {
                        await context.PostAsync("Mail Sent.");
                        })
                        .Build();
            }
        }
ai lover
  • 21
  • 4
  • I think whoever giving negative feedback should also a comment that for which he is doing it by which I should rectify my issue. Thank You. – ai lover Dec 20 '16 at 17:53
  • I ended up here looking for an answer to something similar. Please clean up your question so that it flows correctly. You state you have (had) 4 dialogs; but this is incorrect, it should be Forms, not dialogs - specifically, rootFORM, contactFORM and mailFORM... – zxed Jan 20 '17 at 15:44
  • @zxed thanks for the feedback, currently I am traveling and unable to edit perfectly from mobile, will do that asap :) – ai lover Jan 22 '17 at 14:18

2 Answers2

1

To call a dialog, you need to use context.Call as explained in this post. However, I'm not fully sure if this will work in the OnCompletion event of a Form.

If it doesn't work, my recommendation would be to encapsulate the RootForm into a IDialog<object> dialog and use that dialog as the starting point for the Conversation.SendAsync of the controller.

Community
  • 1
  • 1
Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43
0

You can use below line of code to call multiple dialogs:

await Task.Run(() => context.Call(new OptionDialog(),
    this.OptionDialogResumeAfter)).ConfigureAwait(false);
sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
Upendra
  • 53
  • 1
  • 8