2

I'm using Twilio to connect my "users" with my on-call "staff", but I want to use masked calling as the staff are remote and I need to track how long the calls lasted, so don't want them having each others numbers.

This is all working perfectly using TwiML, but I have the issue that my staff may not answer a call, and the user will be sent to their answering machine. My server will then detect the call was longer than 0 seconds, and will charge the user even though they only got through to the answering machine... So the Answering Machine Detection sounds like what I need: https://www.twilio.com/docs/api/voice/answering-machine-detection

However this doesn't give any examples for use with TwiML. It would seem based off this question that it is not usable? (Using Answering machine detection on Twiml)

So is there any update since the linked answer? Or is it possible for me to do the masked calls without TwiML? Does the response.SetOption method provide anything useful for this or will I have to live without Answering Machine Detection?

At present my code that generates the TwiML for the TwiML App is like this:

   public static string TwiMLDial(string maskedNumber, string to, string callCompleteURL)
    {
        var response = new Twilio.TwiML.VoiceResponse();
        var dial = new Twilio.TwiML.Voice.Dial(action: new Uri(callCompleteURL), callerId: maskedNumber);
        dial.Number(to);
        response.Gather();
        response.Dial(dial);
        return response.ToString();
    }
James
  • 4,146
  • 1
  • 20
  • 35

1 Answers1

2

Twilio developer evangelist here.

You're right, you can't use the Answering Machine detection from TwiML. As an alternative, what you could do is put the dialling user straight into a queue (using <Enqueue>) and then dial your staff using the REST API and Answering machine detection. If the staff answer the call, connect them to the dialler by <Dial>ling the <Queue>.

Let me know if that helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Hey thanks, sounds like what I need. Will give it a go and let you know! – James Dec 08 '17 at 10:51
  • I can't seem to find the correct place to put my "callCompleteURL" now. If I put it on the Enqueue action it comes back when the client leaves the queue (with duration of 0 seconds). If I Put it on the staff dial, it also says a duration of 0 seconds.... – James Dec 08 '17 at 16:41
  • I would place it as the ``'s `action` attribute. Is that what you've got? Alternatively, you can set a [`StatusCallback` parameter on the REST API request](https://www.twilio.com/docs/api/voice/making-calls#optional-parameters) that you can use to tell when then call is over. – philnash Dec 11 '17 at 00:47
  • Yeah that is where I had it, using `DialCallDuration` and `CallDuration` both are 0. StatusCallback seems to give me the full length of the user's call, including time spent in queue. I think I'll just record the time myself between callbacks of the dial `actionURL` and the queue `url` – James Dec 12 '17 at 14:33