使用 luis 动作绑定显示 herocard
display a herocard using luis action binding
如何使用 node.js 在 LUIS 操作绑定的 fulfill() 函数中创建和显示 "HeroCard"?我正在关注 Microsoft(https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/blog-LUISActionBinding)
提供的示例
这是我尝试这样做的方式...
fulfill: function (parameters, callback) {
utilities.FilterFunction(parameters.x, parameters.y).then(function (matches){
utilities.CreateCard(session, matches).then(function(cards){
var reply = new builder.Message(session)
.attachmentLayout(builder.AttachmentLayout.carousel)
.attachments(cards);
callback(util.format(reply));
});
});
}
如何在 fulfill 方法中使用会话值?...没有会话 "utilities.CreateCard" 将无法工作...
由于 session
在操作的 fulfill 方法中不可用,我们只能通过 callback
调用 utilities.FilterFunction
和 return 结果。现在在我们的主 js 文件中,在 fulfillReplyHandler
中我们得到 actionModel
,其中包含 utilities.FilterFunction
的结果。
现在我们可以使用 fulfillReplyHandler
中可访问的 "session" 创建 "HeroCard"。
如何使用 node.js 在 LUIS 操作绑定的 fulfill() 函数中创建和显示 "HeroCard"?我正在关注 Microsoft(https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/blog-LUISActionBinding)
提供的示例这是我尝试这样做的方式...
fulfill: function (parameters, callback) {
utilities.FilterFunction(parameters.x, parameters.y).then(function (matches){
utilities.CreateCard(session, matches).then(function(cards){
var reply = new builder.Message(session)
.attachmentLayout(builder.AttachmentLayout.carousel)
.attachments(cards);
callback(util.format(reply));
});
});
}
如何在 fulfill 方法中使用会话值?...没有会话 "utilities.CreateCard" 将无法工作...
由于 session
在操作的 fulfill 方法中不可用,我们只能通过 callback
调用 utilities.FilterFunction
和 return 结果。现在在我们的主 js 文件中,在 fulfillReplyHandler
中我们得到 actionModel
,其中包含 utilities.FilterFunction
的结果。
现在我们可以使用 fulfillReplyHandler
中可访问的 "session" 创建 "HeroCard"。