Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.post('/voice', function (req, res) {
// Create TwiML response
var twiml = new twilio.TwimlResponse();
if(req.body.To) {
twiml.dial({ callerId: '+15017250604'}, function() {
// wrap the phone number or client name in the appropriate TwiML verb
// by checking if the number given has only digits and format symbols
if (/^[\d\+\-\(\) ]+$/.test(req.body.To)) {
this.number(req.body.To);
} else {
this.client(req.body.To);
}
});
} else {
twiml.say("Thanks for calling!");
}
res.set('Content-Type', 'text/xml');
app.post('/voice', (request, response) => {
// Get information about the incoming call, like the city associated
// with the phone number (if Twilio can discover it)
let city = request.body.FromCity;
// Use the Twilio Node.js SDK to build an XML response
let twiml = new twilio.TwimlResponse();
twiml.say(`Never gonna give you up ${city}.`, {
voice: 'alice'
});
twiml.play('https://demo.twilio.com/docs/classic.mp3');
// Render the response as XML in reply to the webhook request
response.type('text/xml');
response.send(twiml.toString());
});
}, function(err, data) {
if (err) {
console.log(err);
context.fail(err);
} else {
var resp = new twilio.TwimlResponse();
resp.message("Thank you for casting a vote for " + votedFor);
context.done(null, [resp.toString()]);
console.log("Vote received for %s", votedFor);
}
});
} else {
http.createServer(function (req, res) {
//Create TwiML response
var twiml = new twilio.TwimlResponse();
twiml.say("Hello. It's me.");
twiml.play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3");
res.writeHead(200, {'Content-Type': 'text/xml'});
res.end(twiml.toString());
}).listen(1337, '127.0.0.1');
http.createServer(function (req, res) {
//Create TwiML response
var twiml = new twilio.TwimlResponse();
twiml.say("Hello. It's me.");
twiml.play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3");
res.writeHead(200, {'Content-Type': 'text/xml'});
res.end(twiml.toString());
}).listen(1337, '127.0.0.1');
router.post('/holding', twilio.webhook(twilio_auth_token), function (req, res) {
log.info(req.body.CallSid + '-> calls/holding')
log.debug(req.body)
var twiml = new twilio.TwimlResponse()
twiml.pause({length: 5})
.say("I'm still thinking")
.redirect('/calls/holding')
res.send(twiml)
})
var redirectWelcome = function () {
var twiml = new twilio.TwimlResponse();
twiml.say("Returning to the main menu", {voice: "alice", language: "en-GB"});
twiml.redirect("/voice");
return twiml;
};
((urlFor) => (new twilio_1.TwimlResponse()).play({ loop: 1000 }, urlFor(path.normalize(staticFilesMountPath + '/' + holdMusicFileUri), { absolute: true })));
if (!holdMusicFileUri) {
app.post('/call', function(req, res) {
var number = req.query.number;
var eventName = req.query.eventName;
var resp = new twilio.TwimlResponse();
resp.say('Your meeting ' + eventName + ' is starting.', {
voice: 'alice',
language: 'en-gb'
}).dial(number);
res.writeHead(200, {
'Content-Type': 'text/xml'
});
res.end(resp.toString());
});