// 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()); });
twiml.redirect('/authenticate'); } else { utilities.speak(twiml, 'Thank you, recording received, you will now be asked to record your phrase again'); twiml.redirect('/enroll?enrollCount=' + enrollCount); body = JSON.stringify(body); utilities.speak(twiml, 'Your recording was not successful, please try again'); twiml.redirect('/enroll?enrollCount=' + enrollCount); res.send(twiml.toString());
console.log("Create User Responded with the JSON: ", createUserResponse); utilities.speak(twiml, "You have chosen to create a new account with your Voice, you will now be asked to say a phrase three times, then you will be able to log in with that phrase"); twiml.redirect('/enroll'); res.type('text/xml'); res.send(twiml.toString()); const enrollmentsCount = JSON.parse(getEnrollmentsCountResponse).Result; if(enrollmentsCount > 2){ twiml.redirect('/authenticate'); res.type('text/xml'); res.send(twiml.toString()); twiml.redirect('/enroll?enrollCount=' + enrollmentsCount); res.type('text/xml'); res.send(twiml.toString());
const gather = twiml.gather({ action: '/enroll_or_authenticate', numDigits: 1, twiml.redirect('/enroll_or_authenticate?digits=TIMEOUT'); res.send(twiml.toString()); } else { createUserResponse = JSON.parse(createUserResponse); utilities.speak(twiml, "Welcome to eBay Voice ID Demo, you are a new user and will now be enrolled"); twiml.redirect('/enroll'); res.type('text/xml'); 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());