This repository was archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathadd-entity-list.js
More file actions
68 lines (55 loc) · 1.9 KB
/
add-entity-list.js
File metadata and controls
68 lines (55 loc) · 1.9 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*-----------------------------------------------------------------------------
This template demonstrates how to use list entities.
.
For a complete walkthrough, see the article at
https://aka.ms/luis-tutorial-list-entity
-----------------------------------------------------------------------------*/
// NPM Dependencies
var request = require('request-promise');
// To run this sample, change these constants.
// Authoring/starter key, available in www.luis.ai under Account Settings
const authoringKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// ID of your LUIS app to which you want to add an utterance
const appId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
// Version number of your LUIS app
const versionId = "0.1";
// Region of app
const region = "westus";
// Construct HTTP uri
const uri= `https://${region}.api.cognitive.microsoft.com/luis/api/v2.0/apps/${appId}/versions/${versionId}/closedlists`;
// create list entity
var addListEntity = async () => {
try {
// LUIS model definition for list entity
var body = {
"name": "DevicesList",
"sublists":
[
{
"canonicalForm": "Thermostat",
"list": [ "ac", "a/c", "a-c","heater","hot","hotter","cold","colder" ]
}
]
}
// HTTP request
var myHTTPrequest = request({
uri: uri,
method: 'POST',
headers: {
'Ocp-Apim-Subscription-Key': authoringKey
},
json: true,
body: body
});
return await myHTTPrequest;
} catch (err) {
throw err;
}
}
// MAIN
addListEntity().then( (response) => {
// return GUID of list entity model
console.log(response);
}).catch(err => {
console.log(`Error adding list entity: ${err.message} `);
});