I have a simple form,
[Serializable]
class CreateNewLeadForm
{
public string FirstName;
public string LastName;
public static IForm<CreateNewLeadForm> BuildForm()
{
return new FormBuilder<CreateNewLeadForm>()
.Message("Lets create a New Lead")
.Field(nameof(FirstName))
.Field(nameof(LastName))
.Build();
}
};
And a simple Dialog,
public class GreetDialog : IDialog<object>
{
public async Task StartAsync(IDialogContext context)
{
context.Wait(MessageReceivedAsync);
}
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<Message> argument)
{
context.Wait(MessageReceivedAsync);
}
}
How do I call a Initiate a FormDialog from the main Dialog itself? In general how do we intiate new dialogs within a Dialog?
In order to initiate a FormDialog you can just do:
var myform = new FormDialog<CreateNewLeadForm>(new CreateNewLeadForm(), CreateNewLeadForm.BuildForm, FormOptions.PromptInStart, null);
context.Call<CreateNewLeadForm>(myform, FormCompleteCallback);
Take a look to the PizzaBot for an example.
To initiate new dialogs within a Dialog you can do:
context.Forward where you can forward the message to the child dialog
context.Forward(new MyChildDialog(), ResumeAfterChildDialog, message, CancellationToken.None);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With