我正在尝试获取对builder.Prompt.choice(...)的响应;选择列表被加载,当我做出选择时,没有任何事情发生。
但似乎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 :(得分:3)
您应该将方括号放在函数部分的开头,即逗号之后 比如“'LifecycleDialog', [ function(session,args)”
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'
});
答案 1 :(得分: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'
});