-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
21 lines (17 loc) · 791 Bytes
/
server.js
File metadata and controls
21 lines (17 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const express = require('express');
const app = express();
const persephonySDK = require('@persephony/sdk');
var port = process.env.PORT || 3000;
// your Persephony API key (available in the Dashboard) - be sure to set up
// environment variables to store these values
const accountId = process.env.accountId;
const authToken = process.env.authToken;
const persephony = persephonySDK(accountId, authToken);
// Handles incoming requests on the /voice endpoint
app.post('/voice', (req, res) => {
// Create Say script to greet caller
const hello = persephony.percl.say('Hello world!');
// Add greeting to PerCL script and append to response
res.status(200).json(persephony.percl.build(hello));
});
app.listen(port, () => console.log(`Hello Persephony listening on port ${port}!`));