-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.ts
52 lines (40 loc) · 1.19 KB
/
app.ts
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
import { App } from 'jovo-framework';
import { NlpjsNlu } from 'jovo-nlu-nlpjs';
import { WebPlatform } from 'jovo-platform-web';
import { ActionType } from 'jovo-platform-core';
import { FileDb } from 'jovo-db-filedb';
// ------------------------------------------------------------------
// APP INITIALIZATION
// ------------------------------------------------------------------
const app = new App();
const webPlatform = new WebPlatform();
webPlatform.use(
new NlpjsNlu(),
);
app.use(webPlatform, new FileDb());
// ------------------------------------------------------------------
// APP LOGIC
// ------------------------------------------------------------------
app.setHandler({
LAUNCH() {
return this.tell('You can say "switch to dark mode" or "light mode."');
},
SwitchThemeIntent() {
const theme = this.$inputs.theme?.key;
if (theme !== 'dark' && theme !== 'light') {
return this.toIntent('Unhandled');
}
this.$webApp?.addActions([
{
type: ActionType.Custom,
command: 'set-theme',
value: theme,
},
]);
return this.tell(`OK, ${theme} mode.`);
},
Unhandled() {
return this.toIntent('LAUNCH');
}
});
export { app };