简体   繁体   中英

Twilo How to Handle the Timeout in Dial

I need to record a voice of my clients who is try to reach one of our advisors. This should happen when there is timeout

  1. User calls -->Number-----> If timeout --> say(Record your message)--> on end of the recording it should call the recordingStatusCallBack

  2. User Call --> Number --> answer call success --> On end of the call it should call method. Not sure where should we put the action either on number (statuscallback) or on the dial Action verb?

To achieve this I am try with the below twiML

<Response>
   <Dial callerId="+123124" record="true" timeout="10">
  <Number 
  statusCallback="https://<123134>.ngrok.io/ttwilio/callStatusCallBack" 
  statusCallbackEvent="completed" 
  statusCallbackMethod="POST">+1232424/Number>
 </Dial> 
 <Say>Please Record you message</Say> 
   <Record 
     recordingStatusCallback=
      "https://<123134>.ngrok.io/ttwilio/callStatusCallback" 
       recordingStatusCallbackMethod="POST"/>
</Response>

This works fine when there is a timeout but when the call is successfully ended twilio still ask for the user to "Please Record you message"

How to achieve this task?

Twilio developer evangelist here.

The behaviour of <Dial> when there is no action attribute is to continue with the TwiML below it once the call is finished, whether by timeout or through a successful call.

If you add a URL as the action attribute, then the behaviour changes and <Dial> will always make a request to the action URL once the call is completed. The important difference here though, is that the URL will be called with a DialCallStatus parameter that will be one of "completed", "answered", "busy", "no-answer", "failed" and "canceled". This way you can check if the call was busy or not answered and return the TwiML for recording a message. Or if the call was completed successfully, you can just return <Hangup/> .

Let me know if that helps at all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM