// Authentication Recording app.post('/authenticate', function(req, res) { var twiml = new VoiceResponse(); utilities.speak(twiml, 'Please say the following phrase to authenticate '); utilities.speak(twiml, config.chosenVoicePrintPhrase, config.contentLanguage); twiml.record({ action: '/process_authentication', maxLength: '5', trim: 'do-not-trim', }); res.type('text/xml'); res.send(twiml.toString()); });
// Enrollment Recording app.post('/enroll', function(req, res) { const enrollCount = req.query.enrollCount || 0; const twiml = new VoiceResponse(); utilities.speak(twiml, 'Please say the following phrase to enroll '); utilities.speak(twiml, config.chosenVoicePrintPhrase, config.contentLanguage); twiml.record({ action: '/process_enrollment?enrollCount=' + enrollCount, maxLength: 5, trim: 'do-not-trim' }); res.type('text/xml'); res.send(twiml.toString()); });
// This route is called by Twilio to receive TwiML instructions for // voice calls. The Twilio API for voice calling requires that a URL be // specified to obtain the TwiML code it needs to generate the voice message. // In order to put our message content into a voice call we give Twilio // a URL pointing to our own server, which contains the message text encoded // in it. When the call is answered, Twilio sends a request to this // URL, and our server responds with TwiML containing the decoded message text // and the configured voice for the text-to-speech conversion. router.post('/message/:message', function(req, res, next) { const message = decodeURIComponent(req.params.message) console.log('Making TwiML for voice message') const twiml = new VoiceResponse() twiml.say({ voice: config.voice }, message) res.type('text/xml') res.send(twiml.toString()) })
/** * API to lister to call forward request to agent * * @param {Object} req - request object * @param {Object} res - response object **/ app.post('/connect-agent', (req, res) => { const twiml = new twilio.twiml.VoiceResponse(); twiml.dial({ action: '/handle-dial-call-status', method: 'POST', timeLimit: 60, callerId: req.body.To }, '<TEST_PHONE_NUMBER_TO_RECEIVE_INCOMING_CALLS>'); res.type('text/xml'); res.send(twiml.toString()); });
/** * API to lister to call forward request * * @param {Object} req - request object * @param {Object} res - response object **/ app.post('/call-forward', (req, res) => { io.sockets.emit('incoming_call', { callInfo: req.body }); const twiml = new twilio.twiml.VoiceResponse(); twiml.dial({ action: '/handle-dial-call-status', method: 'POST', timeLimit: 60 }, '<TEST_PHONE_NUMBER_TO_RECEIVE_INCOMING_CALLS>'); res.type('text/xml'); res.send(twiml.toString()); });
res.send(twiml.toString());
res.send(twiml.toString()); if(theResult.ResponseCode === "SUC" || theResult.ResponseCode === "ATF" ){ auth200Logic(twiml,theResult); res.send(twiml.toString()); } else{ authNot200Logic(twiml,theResult); res.send(twiml.toString()); authNot200Logic(twiml,authResponse); res.type('text/xml'); res.send(twiml.toString());