如何在第一个LUIS对话框中调用新的第二个LUIS对话框?

时间:2017-03-24 20:20:39

标签: c# botframework luis

Hy,对于我的Bot,我需要调用第二个LUIS对话框实例。但是在第一个LUIS对话框中使用Forward功能,只有正常的对话框可以工作。意图识别不起作用。

那么如何在第一个LUIS对话框中调用新的第二个LUIS对话框?

MessagesController:

[LuisModel("luis", "key")]
[Serializable]
public class FirstDialogClass: LuisDialog<object>
{
    [LuisIntent("")]
    public async Task None(IDialogContext context, LuisResult result)
    {
        await context.PostAsync("intension first dialog: none");
        // call second luis instance
        await context.Forward(new SecondDialogClass(), CallbackFirstDialog, "message", CancellationToken.None);
    }


    [LuisIntent("Greeting")]
    public async Task Hallo(IDialogContext context, LuisResult result)
    {
        await context.PostAsync("intension first dialog: greeting");
        context.Wait(MessageReceived);
    }


    private async Task CallbackFirstDialog(IDialogContext context, IAwaitable<object> result)
    {
        await context.PostAsync("callback first dialog");
        context.Wait(MessageReceived);
    }
}

FirstDialogClass:

[LuisModel("luis", "key")]
[Serializable]
public class SecondDialogClass : LuisDialog<object>
{
    [LuisIntent("")]
    public async Task None(IDialogContext context, LuisResult result)
    {
        await context.PostAsync("intension second dialog: none");
        context.Done(new Object());
    }


    [LuisIntent("Alphabet")]
    public async Task Alphabet(IDialogContext context, LuisResult result)
    {
        await context.PostAsync("intension second dialog: alphabet");
        context.Done(new Object());
    }
}

SecondDialogClass:

.foo

1 个答案:

答案 0 :(得分:2)

我自己找到了解决方案。

[LuisIntent("")]
public async Task None(IDialogContext context, LuisResult result)
{
    await context.PostAsync("intension first dialog: none");
    // call second luis instance
    var message = context.MakeMessage();    // create a message
    message.Text = "abc";   // alphabet intension is called
    await context.Forward(new SecondDialogClass(), CallbackFirstDialog, message, CancellationToken.None);
}