Search code examples
node.jsazure-language-understanding

How to capture the LUIS JSON response to a user's input using LUIS recognizer in node js


// Assigning the published LUIS app URL which is obtained after training the related utterances in LUIS.

LuisModelUrl = 'https://' + luisAPIHostName + '/luis/v2.0/apps/' + luisAppId + '?subscription-key=' + luisAPIKey+'/&verbose=true&q= /';

console.log(LuisModelUrl);

//recognizing the intents using LUIS Recognizer
var recognizerData = new builder.LuisRecognizer(LuisModelUrl);

console.log("------------"+JSON.stringify(recognizerData.intents));

can somebody guide on how to do this using node js.


Solution

  • If you just want to perform one-time calls to LUIS instead of plugging the LuisRecognizer into a bot, LuisRecognizer has a static recognize method that you can use to call your LUIS model.

    LuisModelUrl = 'https://' + luisAPIHostName + '/luis/v2.0/apps/' + luisAppId +
        '?subscription-key=' + luisAPIKey+'/&verbose=true&q= /'
    
    // Callback that console logs the intents
    function printData (err, intents, entities) {
        if (err) {
            throw err
        }
        console.log("------------"+ JSON.stringify(intents))
    }
    
    //recognizing the intents using LUIS Recognizer
    builder.LuisRecognizer.recognize('I love chairs', LuisModelUrl, printData)