【问题标题】:Call FormDialog from within a LUIS Dialog从 LUIS 对话框中调用 FormDialog
【发布时间】:2016-12-07 16:46:03
【问题描述】:

我卡在我的 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?

感谢您的帮助。

【问题讨论】:

    标签: bots botframework azure-language-understanding


    【解决方案1】:

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

    【讨论】:

    • 嘿,你能指定你在上面的例子中所做的哪些更改可以正常运行吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-24
    相关资源
    最近更新 更多