I am building an application of calls with Twilio.
I can make the call from browser to mobile and its working fine. but I cant handle the situation when a call is rejected from mobile.
If a call rejected from mobile I need to show "The customer is Busy" in browser.
I have tried …
var outcall = outGoingDevice.connect(params);
outcall.on('ringing', function(call) {
console.log('Outgoing call Ringing');
if(call) $('.callStatus').html('Ringing...').show();
})
outcall.on('accept', function(call) {
console.log('Outgoing call Accepted');
$('.callStatus').hide();
startTimerOut();
})
outcall.on('disconnect', function(call) {
console.log('Outgoing call Disconnected');
$('.callStatus').hide();
resetTimerOut();
})
In my case when call to a number, it reject from mobile -> going to inside ringing + accept + disconnect methods
Is there any busy method available in twilio sdk..? I am using 1x version for my project...
Twilio developer evangelist here.
The Voice SDK itself doesn't have access to the final status of a call. What you need to do instead is register a statusCallback URL on your <Number> within the <Dial> TwiML. When the call ends, Twilio will send a webhook to the statusCallback URL with the parameter CallStatus. That status will tell you whether the call was: queued, ringing, in-progress, completed, busy, failed, no-answer or canceled.
You would have to send that status to your front-end somehow, but that's the best way to capture why a call finished.