Showing
2 changed files
with
34 additions
and
0 deletions
... | @@ -6,6 +6,22 @@ const app = express(); | ... | @@ -6,6 +6,22 @@ const app = express(); |
6 | app.use(bodyParser.urlencoded({ extended: true })); | 6 | app.use(bodyParser.urlencoded({ extended: true })); |
7 | app.use(bodyParser.json()); | 7 | app.use(bodyParser.json()); |
8 | 8 | ||
9 | +app.use('/api/dialogflow', require('./server/routes/dialogflow')); | ||
10 | + | ||
11 | +// Serve static assets if in production | ||
12 | +if (process.env.NODE_ENV === "production") { | ||
13 | + | ||
14 | + // Set static folder | ||
15 | + app.use(express.static("client/build")); | ||
16 | + | ||
17 | + // index.html for all page routes | ||
18 | + app.get("*", (req, res) => { | ||
19 | + res.sendFile(path.resolve(__dirname, "client", "build", "index.html")); | ||
20 | + }); | ||
21 | +} | ||
22 | + | ||
23 | +const port = process.env.PORT || 5000; | ||
24 | + | ||
9 | app.listen(port, () => { | 25 | app.listen(port, () => { |
10 | console.log(`Server Running at ${port}`) | 26 | console.log(`Server Running at ${port}`) |
11 | }); | 27 | }); | ... | ... |
1 | const express = require('express'); | 1 | const express = require('express'); |
2 | const router = express.Router(); | 2 | const router = express.Router(); |
3 | +const dialogflow = require('dialogflow'); | ||
4 | + | ||
5 | +const config = require('../config/keys'); | ||
6 | + | ||
7 | +const projectId = config.googleProjectID | ||
8 | +const sessionId = config.dialogFlowSessionID | ||
9 | +const languageCode = config.dialogFlowSessionLanguageCode | ||
10 | + | ||
11 | +// Create a new session | ||
12 | +const sessionClient = new dialogflow.SessionsClient(); | ||
13 | +const sessionPath = sessionClient.sessionPath(projectId, sessionId); | ||
14 | + | ||
15 | +//Text Query Route | ||
16 | + | ||
17 | +// Event Query Route | ||
18 | + | ||
19 | + | ||
20 | +module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment