我有一个简单的表格,
[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);
}
}
如何从主Dialog本身调用Initiate a FormDialog?一般来说,我们如何在Dialog中开始新的对话框?
答案 0 :(得分:7)
为了启动FormDialog,你可以这样做:
var myform = new FormDialog<CreateNewLeadForm>(new CreateNewLeadForm(), CreateNewLeadForm.BuildForm, FormOptions.PromptInStart, null);
context.Call<CreateNewLeadForm>(myform, FormCompleteCallback);
查看PizzaBot的示例。
要在对话框中启动新对话框,您可以执行以下操作:
context.Forward,您可以将消息转发到子对话框
context.Forward(new MyChildDialog(),ResumeAfterChildDialog,message,CancellationToken.None);