export.handler = function(context, event, callback) { let twiml = new Twilio.twiml.VoiceResponse();
if (event.AnsweredBy.toLowerCase() == 'machine_start' || event.CallStatus.toLowerCase() == 'no-answer') { // Redirect to another Function twiml.redirect({ method: 'POST' } else { // Add business logic for answered calls }
callback(null, twiml);}
export.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse(); let answeredBy = answeredBy ? answeredBy.toLowerCase() : null; switch(answeredBy) { // Redirect if a Human answered case 'human': twiml.redirect({method:'POST'}, 'http://twilio.com/handle-human); break; // Redirect if a Fax machine answered case 'fax': wiml.redirect({method:'POST'}, 'http://twilio.com/handle-fax); break; // Redirect if AMD detected a machine case 'machine_start': case 'machine_end_beep': case 'machine_end_silence': case 'machine_end_other': twiml.redirect({method:'POST'}, 'http://twilio.com/handle-machine); break; // Handle all other cases case 'unknown': default: twiml.redirect({method:'POST'}, 'http://twilio.com/handle-unknown); }
callback(null, twiml);}