-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVoiceService.js
More file actions
24 lines (18 loc) · 768 Bytes
/
VoiceService.js
File metadata and controls
24 lines (18 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const express = require("express");
const VoiceResponse = require("twilio").twiml.VoiceResponse;
const app = express();
// Returns TwiML which prompts the caller to record a message
app.post("/record", (request, response) => {
// Use the Twilio Node.js SDK to build an XML response
const twiml = new VoiceResponse();
twiml.say("Hello. Please leave a message after the beep.");
// Use <Record> to record and transcribe the caller's message
twiml.record({ transcribe: true, maxLength: 30 });
// End the call with <Hangup>
twiml.hangup();
// Render the response as XML in reply to the webhook request
response.type("text/xml");
response.send(twiml.toString());
});
// Create an HTTP server and listen for requests on port 3000
app.listen(3001);