2017-08-03 18 views
0

我想獲得builder.Prompt.choice(...)的響應;選擇列表被加載,當我做出選擇時,什麼都不會發生。如何從提示在Bot框架對話框中獲得結果

但似乎並不像function(session, results)永遠得到執行。 session.send("Choice Made)而其他代碼不會被執行。我怎樣才能得到我的迴應。我不確定這裏發生了什麼問題。它看起來就像來自文檔的代碼。

bot.dialog('LifecycleDialog', function (session, args) { 

     var softwareEntity = builder.EntityRecognizer.findEntity(args.intent.entities, 'Software'); 
     var choices = Object.keys(SoftwareDict[softwareEntity.entity]); 

     builder.Prompts.choice(session, "Select a version by typing the number: ", choices, "Sorry I don't see that version."); 
     }, 
     function (session, results) { 
      session.send("Choice Made"); //DOES NOT WORK 
       session.endDialogWithResult(results); //DOES NOT WORK 

}).triggerAction({ 
    matches: 'LifecycleStatus' 
}); 
+0

是否有可能用triggerAction做到這一點?所有的例子都只是對話,語法略有不同。 –

回答

0

我想通了。唯一的區別是對話框應該有括號[]而不是大括號{}。

bot.dialog('LifecycleDialog', function (session, args) [ 

     var softwareEntity = builder.EntityRecognizer.findEntity(args.intent.entities, 'Software'); 
     var choices = Object.keys(SoftwareDict[softwareEntity.entity]); 

     builder.Prompts.choice(session, "Select a version by typing the number: ", choices, "Sorry I don't see that version."); 
     }, 
     function (session, results) { 
      session.send("Choice Made"); //DOES NOT WORK 
       session.endDialogWithResult(results); //DOES NOT WORK 

]).triggerAction({ 
    matches: 'LifecycleStatus' 
}); 
+0

提示後,您可以在對話框處理程序的'results.response'對象中找到所選的選項。 – nilsw

+0

花括號'{}'很好,對話框中的函數應該放在方括號[]中。 – chandan

1

逗號 等之後,你應該把方括號在功能部分,即開始了「‘LifecycleDialog’,[功能(會話參數)」

bot.dialog('LifecycleDialog', [ 
    function (session, args) { 

    var softwareEntity = builder.EntityRecognizer.findEntity(args.intent.entities, 'Software'); 
    var choices = Object.keys(SoftwareDict[softwareEntity.entity]); 

    builder.Prompts.choice(session, "Select a version by typing the number: ", choices, "Sorry I don't see that version."); 
    }, 
    function (session, results) { 
     session.send("Choice Made"); //DOES NOT WORK 
      session.endDialogWithResult(results); //DOES NOT WORK 
    } 

]).triggerAction({ 
matches: 'LifecycleStatus' 
}); 
相關問題