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 pathpublish.js
More file actions
63 lines (50 loc) · 1.67 KB
/
publish.js
File metadata and controls
63 lines (50 loc) · 1.67 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
/*-----------------------------------------------------------------------------
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}/publish`;
// publish
var publish = async () => {
try {
// LUIS publish definition
var body = {
"versionId": "0.1",
"isStaging": false,
"region": "westus"
};
// 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
publish().then( (response) => {
// return GUID of list entity model
console.log(response);
}).catch(err => {
console.log(`Error adding list entity: ${err.message} `);
});