1
votes

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?

1

1 Answers

2
votes

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.