-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcontentRecognizer.js
40 lines (32 loc) · 1.29 KB
/
contentRecognizer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { LuisRecognizer } = require('botbuilder-ai');
class ContentRecognizer {
constructor(config) {
const luisIsConfigured = config && config.applicationId && config.endpointKey && config.endpoint;
if (luisIsConfigured) {
// Set the recognizer options depending on which endpoint version you want to use e.g v2 or v3.
// More details can be found in https://docs.microsoft.com/en-gb/azure/cognitive-services/luis/luis-migration-api-v3
const recognizerOptions = {
apiVersion: 'v3'
};
this.recognizer = new LuisRecognizer(config, recognizerOptions);
}
}
get isConfigured() {
return (this.recognizer !== undefined);
}
/**
* Returns an object with preformatted LUIS results for the bot's dialogs to consume.
* @param {TurnContext} context
*/
async executeLuisQuery(context) {
return await this.recognizer.recognize(context);
}
getResourceEntities(result) {
let fromValue;
if (result.entities.$instance.TechInterests) {
fromValue = result.entities.$instance.From[0].text;
}
console.log(result.entities.$instance);
}
}
module.exports.ContentRecognizer = ContentRecognizer;