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();
}
}
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 theOnCompletion
event of a Form.If it doesn't work, my recommendation would be to encapsulate the
RootForm
into aIDialog<object>
dialog and use that dialog as the starting point for theConversation.SendAsync
of the controller.