Reputation: 753
How to hang up the call whent it's status is in queued state(ringing or initiated)? None of the codes below have any effect on call, call continues to ring untill receiver picks up.Sometimes when agent realizes they are dialing wrong number they need a way to hangup the call in the middle of ringing.
PHP code
$client->calls($callRecord->call_sid)->update([
'status' => 'canceled'
]);
$client->calls($callRecord->call_sid)->update([
'status' => 'completed'
]);
$client->calls($callRecord->call_sid)->update([
'url' => 'mywebsite.com/tw-hangup'
]);
Upvotes: 2
Views: 1328
Reputation: 10791
See the following Twilio Documentation:
Voice API: Call (the last paragraph is most relevant) https://www.twilio.com/docs/voice/api/call
When you redirect an active call to another phone number, Twilio creates an entirely new Call instance for that new phone number. The original call is the parent call, and any additional number dialed establishes a child call. Parent and child calls will have uniquely identifying Call SIDs.
Note that any parent call currently executing a is considered in-progress by Twilio. Even if you've re-directed your initial call to a new number, the parent call is still active, and thus you must use Status=completed to end it.
Unanswered child calls cannot be canceled via the REST API, but the parent call can be modified to point to new TwiML. This action will end the child call.
Upvotes: 2