【问题标题】:How to add additional dialog in bot framework如何在机器人框架中添加额外的对话框
【发布时间】:2016-08-31 08:51:43
【问题描述】:

如何同时进行 2 个对话?我目前正在使用 TextBot 和 LuisDialog 来构建一个机器人。我首先与用户进行对话以获取数据。然后在以不同的方法进行一些处理时,我发现我需要来自用户的额外信息。我如何才能与用户创建新对话以获取附加信息?我在下面有一些代码试图显示我想要做什么。感谢您的建议。

文件 1:foo.js

var dialog = new builder.LuisDialog(model);
var sonnyBot = new builder.TextBot();
sonnyBot.add('/', dialog);
dialog.on('intent_1', [
    function(session, args, next) {
        name = builder.Prompts.text(session,"What is your name?");
    },
    function(session, result) {
        session.dialogData.name= results.response;
        getFamilyTree(session.dialogData.name);
    }
]); 

文件 2:getFamilyTree.js

function getFamilyTree(name) {    
    find family tree for name
    if (need place of birth) {
        begin new dialog
        prompt user place of birth
        get place of birth from user
        end dialog
    }
    finish getting the family tree
}

【问题讨论】:

    标签: node.js botframework


    【解决方案1】:

    我猜你可以传递会话对象,然后使用该对象开始一个新的对话框。

    编辑 1

    你不能用一些类似的东西

    session.beginDialog('/getFamilyTree',{name:result.response});
    

    然后你就可以访问名字了

    args.name 
    

    在“getFamilyTree”对话框中

    【讨论】:

    • 我试过了,它让我开始,但我无法正确关闭新对话框,以便父对话框从正确的位置继续。
    • @Howard 请参阅我的回答中的编辑 1。
    【解决方案2】:

    我在 GitHub 上发布了同样的问题,并从参与 node.js SDK 开发的 Steven Ickman 那里得到了答案。答案的链接是https://github.com/Microsoft/BotBuilder/issues/394#issuecomment-223127365

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-04
      • 1970-01-01
      • 2020-04-16
      • 2017-09-10
      • 2015-10-14
      • 1970-01-01
      相关资源
      最近更新 更多