/** * 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()); });
/** * 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()); });