-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathstartEngines.js
53 lines (47 loc) · 1.6 KB
/
startEngines.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
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
© Copyright IBM Corp. 2017
*/
// Initialize handler
const {handler} = require('skill-sdk-nodejs');
const manifest = require('./res/assets/manifest.json');
const factory = require('skill-sdk-nodejs').factory;
// Expertise configuration
require('dotenv').config();
let started = false;
let startEngines = function (callback) {
if (started) {
if (callback) {
callback();
}
} else {
//initialize wcs in handler
if (manifest.nlu.indexOf('wcs') > -1) {
handler.initialize();
}
let localManifest = JSON.parse(JSON.stringify(manifest));
let index = localManifest.nlu.indexOf('skill');
if (index !== -1) {
localManifest.nlu.splice(index, 1);
}
if (localManifest.nlu.length < 1) {
console.error('No Nlu engines selected, you need to add the nlu engines you want to use to manifest.json nlu field')
} else {
factory.getNLUs(localManifest).then(updatedManifest => {
if (updatedManifest.nlu.regexp) {
updatedManifest.intents = require('./res/nlu/intents');
}
handler.manifest = updatedManifest;
factory.createAll(updatedManifest).then(function (engines) {
handler.engines = engines;
if (callback) {
started = true;
callback();
}
});
});
}
// The expertise handler
require('./actions')();
}
};
module.exports.startEngines = startEngines;