0

For Outbound Calls From An App to a Number,
  There are two legs - One between my browser and Twilio and the other between Twilio and the number to be dialled
  Can I set a webhook to trigger, on each callstatus value change (especially when the Call Status is in-progress) of the second leg and How?
This is necessary so that I can start the timer and show hold button only after the customer picks up the phone
Any other idea to achieve this also Welcome. Thanks in advance.

Aatitya
  • 75
  • 8

1 Answers1

1

Twilio developer evangelist here.

When you dial out from Twilio Client you can send parameters into the request, such as the number, then Twilio will send your application a webhook with those parameters to find out what to do next. To dial a number, you would use the <Dial> verb and nest a <Number> within it.

With a <Number> you can register for webhook callbacks when certain events take place. You do so by setting a statusCallback attribute to the URL that will receive the callback. By default the statusCallback URL will only receive the completed event when the call finishes, however you can register for more events using the statusCallbackEvent attribute.

The event you want to subscribe too is called "answered" and the TwiML you need is:

<Response>
  <Dial>
    <Number statusCallback="http://example.com/calls/callback" statusCallbackEvent="answered">
      NUMBER TO DIAL
    </Number>
  </Dial>
</Response>

Let me know if that helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Awesome! Hope the rest of your app is going well too. – philnash Nov 07 '16 at 10:29
  • @philnash what is the status callback url???. I dont have a url. Iam running the code in python. How can I get the status in my code? – Anesh Jan 23 '19 at 19:43
  • @Anesh take a read through this article, it should explain some things: https://www.twilio.com/docs/sms/tutorials/how-to-confirm-delivery-python – philnash Jan 23 '19 at 21:31
  • Thanks but I need to know the status of the outbound call. I read alll articles and gave ngrok http in status callback url, but iam not getting any information in my python environment. – Anesh Jan 24 '19 at 05:35
  • I see you've asked a [question here](https://stackoverflow.com/questions/54333673/how-to-know-the-status-of-outbound-calls), let's take this discussion over there. – philnash Jan 24 '19 at 05:37