自3.8版以来,bot框架现在包含了如下消息:
DialogAction.ValidatedPrompt()自3.8版起已被弃用。考虑改用自定义提示。
我在文件中没有提到这个。什么是“自定义提示”,在哪里可以了解更多关于它们如何改进不推荐的功能的信息?

最佳答案

您可以在git hubhere上找到一个示例。示例中提供的代码如下:

// 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;
          }
     }
]);

`

07-28 09:09