1

我被困在我的 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;
    }

我的 Resume 方法还没有做太多,只是为了调试。

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

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

感谢您的任何帮助。

4

1 回答 1

2

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

于 2016-12-08T16:01:00.877 回答