-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (41 loc) · 1.25 KB
/
Copy pathindex.js
File metadata and controls
50 lines (41 loc) · 1.25 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
'use strict';
const functions = require('firebase-functions');
const {
dialogflow,
// BasicCard,
// BrowseCarousel,
// BrowseCarouselItem,
// Button,
// Carousel,
// Image,
// LinkOutSuggestion,
// List,
// MediaObject,
// Suggestions,
// SimpleResponse,
// Table,
} = require('actions-on-google');
const app = dialogflow();
// For i18n
const i18n = require('i18n');
i18n.configure({
locales: ['en', 'ja-JP'],
directory: __dirname + '/locales'
});
const moment = require('moment');
app.middleware((conv) => {
i18n.setLocale(conv.user.locale);
moment.locale(conv.user.locale);
});
// For i18n END
app.intent('Default Welcome Intent', (conv) => { // must not be async for i18n
console.log("getCurrentDate : " + getCurrentDate); // getCurrentDate : July 15, 2019
console.log("conv.user.locale : " + conv.user.locale); // conv.user.locale : en-US
const getCurrentDate = moment().format('LL');
conv.ask(i18n.__('WELCOME_BASIC', getCurrentDate));
});
app.intent('date', (conv) => { // must not be async for i18n
conv.ask(i18n.__('DATE', getCurrentDate));
});
//exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
exports.dottdiary = functions.https.onRequest(app);