如何同時進行2個對話?我目前使用TextBot和LuisDialog來構建一個bot。我首先與用戶進行對話以獲取數據。然後以不同的方法進行一些處理時,我發現我需要來自用戶的額外信息。我如何才能與用戶建立新的對話以獲得附加信息?我下面有一些代碼試圖展示我想要做什麼。感謝您的建議。如何在機器人框架中添加其他對話框
文件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
}
我試過了,它讓我開始了,但我無法正確關閉新對話框,以便父對話框從正確的位置繼續。 – Howard
@霍華德請參閱我的答案上的編輯1。 – krazy