Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use IfMachine in TwiML when using <Dial>

Tags:

twilio

Is there a way to use the Dial verb in conjunction with the IfMachine parameter? I don't see anything on the dial verb page (https://www.twilio.com/docs/api/twiml/dial) which indicates the IfMachine parameter can be used or whether it will be passed to the resulting Action parameter.

I found this post Detecting if an answering service picks up, and the answer says "put the IfMachine parameter in your TwiML", but I don't see any examples of the IfMachine parameter being used in TwiML. I've only seen examples of it being used with the REST API.

I'm trying to have my application redirect a call, then if that redirected call was picked up by an answering machine to then send a text message. Ideally the incoming call TwiML would look something like:

<Response>
  <Dial action="/sendSmsIfMachine.cshtml" method="POST" ifMachine="Continue">
    555-5555
  </Dial>
</Response>

Then my sendSmsIfMachine page would have something like:

@{
   Response.ContentType = "text/xml";
   if(Response["AnsweredBy"] == "machine")
   {
      var twimlResponse = new TwilioResponse();
      twimlResponse.Message("You got a voicemail", new { to = "555-5556" });
      Response.Write(twimlResponse.ToString();
   }
 }

When I tried this, the resulting request made to sendSmsIfMachine.cshtml did not include the AnsweredBy parameter according to to the Twilio log.

like image 913
almisson Avatar asked Jul 08 '14 21:07

almisson


1 Answers

No Twiml Doesn't support (AMD) ifMachine parameter. I've contacted Twilio about this issue and below is there response.

Hi Sisir,

Thanks for the question. No, AMD is not supported by TwiML, only by the API. This means that IfMachine and AnsweredBy are only valid for calls initiated by the REST API.

This was a deliberate exclusion when we released AMD. The way machine detection works is it listens to the answering party for a second before connecting the call. Then if it hears audio patterns that sound like a human, it lets the calls connect.

The problem with calls on is that there is usually a user on the line already waiting for the called party to pick up. So, if the machine detection "eats" the first second of the call, the person already on the phone doesn't hear the called party say "Hello." This causes a bit of an awkward silence.

Best Regards,

Twilio Customer Support

So, if you want to use there AMD feature you MUST use REST API.

like image 189
Sisir Avatar answered Oct 16 '22 13:10

Sisir