Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...