从对话框中调用表单
Calling Forms from Dialogs
我有一个简单的表格,
[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);
}
}
如何从主对话框本身调用 Initiate FormDialog?一般来说,我们如何在对话框中启动新对话框?
要启动 FormDialog,您只需执行以下操作:
var myform = new FormDialog<CreateNewLeadForm>(new CreateNewLeadForm(), CreateNewLeadForm.BuildForm, FormOptions.PromptInStart, null);
context.Call<CreateNewLeadForm>(myform, FormCompleteCallback);
查看 PizzaBot 示例。
要在对话框中启动新对话框,您可以执行以下操作:
- context.Call 传递新对话框的实例和完成回调(如在表单中)
context.Forward 您可以在其中转发 消息到子对话框
context.Forward(new MyChildDialog(), ResumeAfterChildDialog, 消息, CancellationToken.None);
我有一个简单的表格,
[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);
}
}
如何从主对话框本身调用 Initiate FormDialog?一般来说,我们如何在对话框中启动新对话框?
要启动 FormDialog,您只需执行以下操作:
var myform = new FormDialog<CreateNewLeadForm>(new CreateNewLeadForm(), CreateNewLeadForm.BuildForm, FormOptions.PromptInStart, null);
context.Call<CreateNewLeadForm>(myform, FormCompleteCallback);
查看 PizzaBot 示例。
要在对话框中启动新对话框,您可以执行以下操作:
- context.Call 传递新对话框的实例和完成回调(如在表单中)
context.Forward 您可以在其中转发 消息到子对话框
context.Forward(new MyChildDialog(), ResumeAfterChildDialog, 消息, CancellationToken.None);