2

I have created a agent in luis with entities and intents and I am unable to add bot response in luis as i can do it in Google API AI can I use luis directly from my node App ??

Techie
  • 19
  • 5

1 Answers1

1

In your node application, you can install the botbuilder package which includes what you need to connect a node app to luis.

npm install botbuilder

Then in your node app,

var builder = require('botbuilder');

The builder module already has what you need to connect to LUIS.

From then, here's how you can connect to your LUIS application:

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

For more samples, you can check out the botbuilder-samples repo. There are a few Node.js bot samples which use LUIS.

However, if you DON'T want to use the botbuilder SDK,

you can use the Programmatic API from LUIS

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

There are several examples in different languages, for example, in Javascript, using 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");
        });

Hope that helps!

Matthew S
  • 308
  • 1
  • 15