首页 > 解决方案 > 是否可以在单个机器人中使用由 Bot Framework Composer 生成的多个自适应对话框?

问题描述

用例:我在前面有一个 LUIS 调度模型 2 个 Composer 构建的 LUIS 模型 - 每个模型前面都有一个 Composer 构建的自适应对话对话。例如

一旦识别出 LUIS 意图,我想过渡到这三个过程中的任何一个。

我将 Composer 生成的自适应对话框集成到 Bot 中的策略基于此处的示例:https ://github.com/microsoft/BotBuilder-Samples/tree/master/experimental/adaptive-dialog/declarative

然后我将这两个过程添加到ResourceExplorer我的适配器中,然后在我的 Bot 中,我正在加载对话框并创建一个父级AdaptiveDialog并将其包装在 a 中DialogManager,然后再委派给OnTurnAsync. :

(注意:我已经剥离并简化了很多代码来帮助我调试问题)

var adaptiveDialogs = new DialogSet();

foreach (var resource in _resourceExplorer.GetResources(".dialog").Where(r => _composedDialogNames.Contains(Path.GetFileNameWithoutExtension(r.Id))))
{
    var subDialog = DeclarativeTypeLoader.Load<AdaptiveDialog>(resource, _resourceExplorer, DebugSupport.SourceMap);
    adaptiveDialogs.Add(subDialog);
}

// Note - at this point adaptiveDialogs correctly contains two Composer created dialogs 

var dialog = new AdaptiveDialog()
{
    AutoEndDialog = false,
    Dialogs = adaptiveDialogs,
    Triggers = new List<OnCondition>() {
        new OnBeginDialog() {
            Actions = new List<Dialog>()
            {
                new CodeAction(async (context, o) =>
                {
                    await context.Context.SendActivityAsync("say something to me");
                    return new DialogTurnResult(DialogTurnStatus.Waiting, o); 
                }),                            
                new BeginDialog(adaptiveDialogs.GetDialogs().ElementAt(0).Id),
                new BeginDialog(adaptiveDialogs.GetDialogs().ElementAt(1).Id),
                new RepeatDialog()
            }
        }
    }
};

我遇到的问题是,当它运行时,new BeginDialog(adaptiveDialogs.GetDialogs().ElementAt(0).Id)如果加载了后续的自适应对话框,则该行不会执行任何操作。(new BeginDialog(adaptiveDialogs.GetDialogs().ElementAt(1).Id)顺便说一句,运行良好)

任何帮助将不胜感激。

标签: botframework

解决方案


推荐阅读