【问题标题】:Bot builder Sdk is the only way to create chatbot with luis? how to add bot response in luisBot builder Sdk 是用 luis 创建聊天机器人的唯一方法吗?如何在 luis 中添加机器人响应
【发布时间】:2018-07-04 15:28:54
【问题描述】:

我在 luis 中创建了一个具有实体和意图的代理,但我无法在 luis 中添加机器人响应,因为我可以在 Google API AI 中执行此操作 我可以直接从我的节点应用程序使用 luis 吗?

【问题讨论】:

    标签: bots azure-language-understanding


    【解决方案1】:

    在您的节点应用程序中,您可以安装 botbuilder 软件包,其中包含将节点应用程序连接到 luis 所需的内容。

    npm install botbuilder

    然后在你的节点应用中,

    var builder = require('botbuilder');
    

    构建器模块已经具备连接到 LUIS 所需的内容。

    从那时起,您可以通过以下方式连接到您的 LUIS 应用程序:

    function initLuisRecognizer(){
        const luisAppID = "Your-luis-app-id"
        const subscriptionKey = "Your-Luis-Sub-Key"
        return new builder.LuisRecognizer(luisAppID, subscriptionKey);
    }
    var luisRecognizer = initLuisRecognizer();
    

    更多示例,您可以查看botbuilder-samples repo。有一些使用 LUIS 的 Node.js 机器人示例。

    但是,如果您想要使用 botbuilder SDK,

    您可以使用Programmatic API from LUIS

    https://[location].api.cognitive.microsoft.com/luis/api/v2.0/apps/

    有几个不同语言的例子,例如,在Javascript中,使用ajax:

         $.ajax({
                url: "https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/?" + $.param(params),
                beforeSend: function(xhrObj){
                    // Request headers
                    xhrObj.setRequestHeader("Content-Type","application/json");
                    xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
                },
                type: "POST",
                // Request body
                data: "{body}",
            })
            .done(function(data) {
                alert("success");
            })
            .fail(function() {
                alert("error");
            });

    希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-19
      • 2020-07-30
      • 1970-01-01
      • 2018-06-23
      • 1970-01-01
      • 1970-01-01
      • 2018-03-25
      • 2019-11-15
      相关资源
      最近更新 更多