从 3.8 版开始,Bot Framework 现在包含一些像这样的消息:
DialogAction.validatedPrompt() has been deprecated as of version 3.8. Consider using custom prompts instead.
我在文档中没有看到任何提及。什么是“自定义提示”,我在哪里可以详细了解它们如何改进已弃用的功能?
最佳答案
您可以在 Git Hub here 上找到示例.那里提供的代码可以在下面的示例中找到:
// Create a recognizer for your LUIS model
var recognizer = new builder.LuisRecognizer('<model>');
// Create a custom prompt
var prompt = new builder.Prompt({ defaultRetryPrompt: "I'm sorry. I didn't recognize your search." })
.onRecognize(function (context, callback) {
// Call prompts recognizer
recognizer.recognize(context, function (err, result) {
// If the intent returned isn't the 'None' intent return it
// as the prompts response.
if (result && result.intent !== 'None') {
callback(null, result.score, result);
} else {
callback(null, 0.0);
}
});
});
// Add your prompt as a dialog to your bot
bot.dialog('myLuisPrompt', prompt);
// Add function for calling your prompt from anywhere
builder.Prompts.myLuisPrompt = function (session, prompt, options) {
var args = options || {};
args.prompt = prompt || options.prompt;
session.beginDialog('myLuisPrompt', args);
}
// Then call it like a builtin prompt:
bot.dialog('foo', [
function (session) {
builder.Prompts.myLuisPrompt(session, "Please say something I recognize");
},
function (session, results) {
switch (results.response.intent) {
case 'Bar':
break;
}
}
]);
`
关于node.js - Microsoft Bot Framework 中的 "custom prompts"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44833679/