我有一个简单的表格,
[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(); } };
还有一个简单的对话框
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); } }
如何从主对话框本身调用“启动FormDialog”?总的来说,我们如何在对话框中创建新对话框?
为了启动FormDialog,您可以执行以下操作:
var myform = new FormDialog<CreateNewLeadForm>(new CreateNewLeadForm(), CreateNewLeadForm.BuildForm, FormOptions.PromptInStart, null); context.Call<CreateNewLeadForm>(myform, FormCompleteCallback);
以PizzaBot为例。
要在对话框中启动新对话框,您可以执行以下操作:
context.Forward(new MyChildDialog(),ResumeAfterChildDialog,消息,CancellationToken.None);