-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathnode_ivr.js
40 lines (35 loc) · 981 Bytes
/
node_ivr.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
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const server = require('http').Server(app);
const port = 5501;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
server.listen(port, (err) => {
if (err) {
throw err;
}
console.log('Server running on port ' + port);
});
var baseURL = "YOUR-SERVER"
app.post('/incomingCall', (req, res) => {
res.status(200);
console.log(req.body);
res.json({
"ivr": "https://46elks.com/static/sound/ivr-menu.mp3",
"digits": 1,
"next": baseURL + "ivr"
})
res.end();
});
app.post('/ivr', (req, res) => {
res.status(200);
let result = req.body.result;
if (result == "1") {
res.json({ 'play': "https://www.46elks.com/static/sound/voiceinfo.mp3" })
}
if (result == "2") {
res.json({ 'play': "https://www.46elks.com/static/sound/smsinfo.mp3" })
}
res.end();
});