从LUIS对话框中调用FormDialog

时间:2016-12-07 16:46:04

标签: bots botframework luis

我被卡在了我的LUIS对话框中。我试图通过

调用FormDialog
[LuisIntent("GetRestaurant")]
    public async Task GetRestaurant(IDialogContext context, LuisResult result) {
        try {
            FormDialog<AddressForm> addressForm = new FormDialog<AddressForm>(new AddressForm(), AddressForm.BuildAddressForm, FormOptions.PromptInStart);
            AddressForm address = new AddressForm();
            context.Call(addressForm, AddressFormCompleteAsync);
    }

在调用之后,我的模拟器在我的表单对话框中返回第一个提示符(哪个城市?),并将下一个输入作为Luis输入并尝试将其与LuisIntent匹配。

我的表格如下:

[Serializable]
public class AddressForm  {

    [Prompt(new string[] { "Which city?" })]
    public string City { get; set; }

    [Prompt("Which street?")]
    public string Street { get; set; }

    [Prompt("Which number?")]
    public string Number { get; set; }

    public static IForm<AddressForm> BuildAddressForm() {
        IForm<AddressForm> addressFrom = new FormBuilder<AddressForm>()
            .Field(nameof(City), validate: ValidateCityInformation)
            .Field(nameof(Street))
            .Field(nameof(Number), validate: ValidateNumberInformation, active: NumberEnabled)
            .Build();
        return addressFrom;
    }

我的简历方法还没有做太多工作,仅用于调试。

private async Task AddressFormCompleteAsync(IDialogContext context, IAwaitable<AddressForm> result) {
        var adress = await result;
        context.Wait(MessageReceived);
    }

如何留在FormDialog中,不要跳回我的LuisDialog? 如果我需要使用context.Forward(),那么我的AddressForm类是否需要是IDialog类型,我如何在AddressFrom类中处理IAwaitable?

感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

我现在想出了答案。它跳出FormDialog,因为提示(在Channel中显示)计为调用方法的一个消息(我称之为LuisDialog),因此FormDialog和LuisDialog获取context.Done。我必须更加小心对话流程。