从 LUIS 对话框中调用 FormDialog
Call FormDialog from within a LUIS Dialog
我卡在了 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);
}
调用后,我的模拟器 returns 在我的表单对话框中出现第一个提示(哪个城市?),并将下一个输入作为 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 class 是否需要是 IDialog 类型以及如何处理 AddressFrom class 中的 IAwaitable?
感谢您的帮助。
我现在找到了答案。它跳出了 FormDialog,因为提示(在 Channel 中显示)算作调用方法(我调用 LuisDialog 的地方)收到的消息,因此 FormDialog 和 LuisDialog 获得 context.Done。我必须更加小心对话流程。
我卡在了 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);
}
调用后,我的模拟器 returns 在我的表单对话框中出现第一个提示(哪个城市?),并将下一个输入作为 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 class 是否需要是 IDialog 类型以及如何处理 AddressFrom class 中的 IAwaitable?
感谢您的帮助。
我现在找到了答案。它跳出了 FormDialog,因为提示(在 Channel 中显示)算作调用方法(我调用 LuisDialog 的地方)收到的消息,因此 FormDialog 和 LuisDialog 获得 context.Done。我必须更加小心对话流程。