0

When the function is configured on a Twilio phone number the function will immediately direct the calling party to voicemail failing to notify the called party of an incoming call and denying the called party (SIP endpoint) (user@domain.sip.us1.twilio.com) the ability to answer call(s).

I have also tried using TwiML XML. When I configure a TwiML XML on a Twilio phone number, the called party (user@domain.sip.us1.twilio.com) is notified of incoming call(s) and is able to answer calls and will automatically direct calling parties to voicemail when the called party is unavailable. However, when the call ends gracefully the calling party is directed to voicemail which is an issue.

exports.handler = function(context, event, callback) {
    let phoneNumber = "sip:user@domain.sip.us1.twilio.com"; 
    const twiml = new Twilio.twiml.VoiceResponse();
    if (event.DialCallStatus === "completed") {
        twiml.hangup();
    } else {
        twiml.say("You have reached users voicemail. Please leave a message and I will get back to you.");
        twiml.record({
            transcribe: true,
            transcribeCallback: "http://twimlets.com/voicemail?Email=user@domain.com",
             action: "/hangup"
        });
    }
callback(null, twiml);
};

The function should provide the called party (user@domain.sip.us1.twilio.com) the ability to answer calls and automatically direct the calling party to voicemail when the called party (user@domain.sip.us1.twilio.com) is unavailable. If there is a way to achieve this with a function or TwiML XML that would be great.

Thank you

1 Answers1

1

You can borrow from the Twilio Function code detailed below, it will do exactly what you are looking for (need to check the DialCallStatus to intelligently determine next steps.

Implement Voicemail

Alan
  • 10,465
  • 2
  • 8
  • 9