问题
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.
回答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.
来源:https://stackoverflow.com/questions/40419512/answered-notification-for-outbound-call-from-an-app-twilio