繁体   English   中英

Microsoft Bot Framework中的“自定义提示”是什么?

[英]What are “custom prompts” in the Microsoft Bot Framework?

从版本3.8开始,Bot Framework现在包含了一些像这样的消息:

从版本3.8开始,不推荐使用DialogAction.validatedPrompt()。 请考虑使用自定义提示。

我在文档中没有看到任何提及。 什么是“自定义提示”,哪里可以了解有关如何改进已弃用功能的更多信息?

你可以在这里找到Git Hub的一个例子。 在下面的例子中可以找到的代码如下:

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

`

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM