Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
421 views
in Technique[技术] by (71.8m points)

twilio - Use IfMachine in TwiML when using <Dial>

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...