Twilio <Dial> Timeout: Inconsistent 'canceled' Status
0 reputation · 21 Jan 2022, 19:18 UTC
0 reputation · 21 Jan 2022, 19:18 UTC
When an outbound call uses the timeout attribute on the <Dial> verb, Twilio waits for the called party to answer. If the caller hangs up before the call is answered, Twilio sends a StatusCallback with a CallStatus value. Although the documentation lists canceled as a possible status, real‑world tests show that this value is not always returned; many carriers deliver no-answer or failed instead.
The uncertainty makes it difficult to implement deterministic cleanup and billing logic. Developers must decide whether to rely on canceled, treat any non‑completed status as a failure, or inspect additional fields such as callDuration to infer the caller’s intent.
What status does Twilio reliably send when a caller ends the call before connection? Are there carrier‑specific differences that affect this value? How can an application reliably detect a user‑initiated hang‑up in all scenarios?
32275 reputation · 22 Jan 2022, 01:48 UTC
There is no single CallStatus value that Twilio reliably sends across all carriers when a caller hangs up before a connection is established. While canceled is the intended status for user-initiated terminations during the dialing phase, carrier-level signaling often maps these disconnects to no-answer or failed.
The discrepancy arises because Twilio maps PSTN (Public Switched Telephone Network) disconnect codes to a simplified set of statuses. Different carriers handle the "caller hang-up" signal differently; some signal a standard disconnect, while others signal a failure to establish the session. Consequently, the StatusCallback may report no-answer even if the caller was the one to terminate the call.
To deterministically detect if a call was never answered (regardless of whether the caller hung up or the timeout expired), you should rely on a combination of CallStatus and CallDuration rather than the status string alone.
CallDuration: A value of 0 confirms the call never reached the "in-progress" state.canceled, no-answer, and failed as a single "Unanswered" category for cleanup and billing logic.completed: Any call with a status of completed and a CallDuration greater than 0 was successfully connected.To map the specific behavior of your target carriers, perform the following test:
<Dial timeout="30"> request.CallStatus and CallDuration received at your StatusCallback URL.Required Diagnostic: To refine this recommendation, please specify if you are dialing primarily to VoIP numbers or traditional PSTN landlines, as signaling behavior differs significantly between the two.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.