从3.8版开始,Bot Framework现在包含了一些像这样的消息:
从版本3.8开始,不推荐使用DialogAction.validatedPrompt()。请考虑使用自定义提示。
我在文档中没有看到任何提及。什么是“自定义提示”,哪里可以了解有关如何改进已弃用功能的更多信息?
答案 0 :(得分:5)
您可以在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;
}
}
]);
`