-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
98 lines (88 loc) · 2.39 KB
/
index.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"use strict";
require("dotenv").config();
/**
* Import Packages
*/
const express = require("express");
const server = express();
const bot_express = require("bot-express");
const path = require('path');
server.set('views', path.join(__dirname, 'views'));
server.set('view engine', 'ejs');
server.use(express.static(path.join(__dirname, 'public')));
/**
* Middleware Configuration
*/
server.listen(process.env.PORT || 5000, () => {
console.log("server is running...");
});
/**
* Mount bot-express
*/
server.use("/bot/webhook", bot_express({
language: process.env.BOT_LANGUAGE || "en",
messenger: {
line: {
channel_id: process.env.LINE_BOT_CHANNEL_ID,
channel_secret: process.env.LINE_BOT_CHANNEL_SECRET
}
},
nlu: {
type: "dialogflow",
options: {
project_id: process.env.GOOGLE_PROJECT_ID,
client_email: process.env.GOOGLE_CLIENT_EMAIL,
private_key: process.env.GOOGLE_PRIVATE_KEY,
language: process.env.BOT_LANGUAGE || "en"
}
},
parser: [{
type: "dialogflow",
options: {
project_id: process.env.GOOGLE_PROJECT_ID,
client_email: process.env.GOOGLE_CLIENT_EMAIL,
private_key: process.env.GOOGLE_PRIVATE_KEY,
language: process.env.BOT_LANGUAGE || "en"
}
}],
memory: {
type: "memory-cache",
retention: Number(process.env.MEMORY_RETENTION)
},
translator: {
type: "google",
enable_lang_detection: true,
enable_translation: true,
options: {
project_id: process.env.GOOGLE_PROJECT_ID,
client_email: process.env.GOOGLE_CLIENT_EMAIL,
private_key: process.env.GOOGLE_PRIVATE_KEY
}
},
skill: {
default: process.env.DEFAULT_SKILL,
follow: "follow"
},
modify_previous_parameter_intent: "modify_previous_parameter"
}));
/**
* Mount LIFF
*/
const routes_liff = require("./routes/liff");
server.use("/liff", routes_liff);
/**
* Mount LINE Pay
*/
const routes_line_pay = require("./routes/line_pay");
server.use("/line_pay", routes_line_pay);
/**
* Mount Stripe
*/
const routes_stripe = require("./routes/stripe");
server.use("/stripe", routes_stripe);
/**
* Mount Console
*/
const routes_console = require("./routes/console");
server.use("/console", routes_console);
module.exports = server;