VMware ESXi and vSphere Cluster Management
Handling Invalid DTMF Entries and Input Timeouts in Asterisk Dialplans
Learn how to use Asterisk's special i and t extensions to handle invalid IVR choices and caller input timeouts gracefully.
An IVR menu is only reliable when it handles more than valid choices. Callers may press an unsupported DTMF digit, enter an unexpected sequence, or remain silent. Asterisk can route these situations to special dialplan extensions so the caller receives a clear response instead of experiencing an abrupt disconnect.
Prerequisites and Key Terms
Asterisk is open-source telephony and PBX software whose dialplan controls call flow. A dialplan is an ordered set of instructions, commonly stored in extensions.conf.
A context is a named dialplan section that limits the extensions and handlers available to a call. An extension is a dialplan match followed by one or more priorities. In an IVR, an extension commonly represents a caller's menu selection. A priority determines the execution order of applications within an extension.
DTMF is the touch-tone signaling produced when a caller presses telephone keypad keys. The same => n notation continues the current extension at the next automatically assigned priority.
Why IVR Input Error Handling Is Necessary
A menu that accepts only a defined set of choices must also account for choices outside that set and for callers who provide no response. For example, a menu may accept digits 1 through 5, while a caller presses 6 or waits silently.
If no matching dialplan extension or fallback handler exists, Asterisk may be unable to continue the intended menu flow. Depending on the surrounding call flow, the caller may hear no useful explanation or the call may end abruptly. That behavior is confusing and makes the menu appear broken.
Invalid-input and timeout branches are therefore required parts of a dependable caller menu. A minimal implementation can explain the problem and hang up. A production implementation might replay the menu, count retries, send the caller to an operator, or route the caller to voicemail.
How Asterisk Matches IVR Input
When a caller enters DTMF digits, Asterisk evaluates those digits against the extensions available in the active dialplan context. A menu with explicit choices might define extensions for digits 1 through 5:
[menu-context]
exten => 1,1,Playback(sales)
same => n,Hangup()
exten => 2,1,Playback(support)
same => n,Hangup()
exten => 3,1,Playback(accounts)
same => n,Hangup()
exten => 4,1,Playback(hours)
same => n,Hangup()
exten => 5,1,Playback(operator)
same => n,Hangup()Here, the digits are normal dialplan extensions representing valid menu choices. If the caller enters 6 and no extension matches it, the input is invalid for the current context. The same principle applies to an unmatched multi-digit sequence: the entered pattern must match an available extension or pattern.
The Special i Extension for Invalid Entries
The special i extension is Asterisk's invalid-extension handler. Asterisk transfers call processing to i when the entered digits do not match an extension in the active context.
Define i in the same context as the IVR choices it protects. It must have at least one priority, and its applications execute in order:
[menu-context]
exten => i,1,Playback(pbx-invalid)
same => n,Hangup()Playback() plays a sound file to the caller. In this example, the recording should tell the caller that the selection is invalid. Hangup() explicitly ends the call after the prompt.
The referenced sound prompt must be available to Asterisk. Replace menu-context with the actual context containing the menu choices.
The Special t Extension for Timeouts
The special t extension is Asterisk's timeout handler. It is used when the caller does not provide input before the configured response timeout expires.
Like i, the t extension must be defined in the same context as the interactive menu:
[menu-context]
exten => t,1,Playback(press-button-again)
same => n,Hangup()The prompt should explain what happened and tell the caller what to do, such as trying again or pressing a button. This minimal example ends the call, but the final priority can instead return the caller to the menu or transfer the call.
Response Timeout and Digit Timeout
For this lesson's menu scenario, assume the default response timeout is 10 seconds. A response timeout is the period Asterisk waits for the first DTMF input after the menu begins waiting for a response. If the caller provides no input during that period, the t branch is reached.
A digit timeout is different. It applies after the caller has started entering a multi-digit input and Asterisk is waiting for the next digit. For example, if a menu expects a multi-digit account code and the caller pauses between digits, the digit timeout may expire even though the caller already pressed a key.
The menu application that collects input and the dialplan timeout settings determine when these events occur. Applications such as Background() play audio while allowing DTMF input to interrupt it, while other applications may collect digits differently. Review the input-collection application and settings such as TIMEOUT(response) and TIMEOUT(digit) when the observed behavior differs from expectations.
| Caller action | Dialplan condition | Special extension used | Typical response |
|---|---|---|---|
| Valid menu digit | An explicit menu extension matches | None | Run the normal option, such as playing information or connecting a call |
| Unsupported digit or unmatched digit sequence | Entered input matches no extension in the active context | i | Play an invalid-selection prompt, then retry, route, or hang up |
| No input before response timeout | The caller enters no digit before the response period expires | t | Play a timeout prompt, then retry, route, or hang up |
Special Extensions Used for Menu Error Handling
| Extension | Trigger | Purpose | Typical next step |
|---|---|---|---|
i | Entered digits fail to match an extension in the current context | Handle invalid DTMF entries | Explain the invalid choice and replay the menu, transfer the caller, or hang up |
t | No input arrives before the response timeout | Handle caller silence or delayed response | Ask the caller to try again, replay the menu, transfer the caller, or hang up |
Complete Minimal Example
The following context shows valid choices together with both error handlers. The menu entry point is represented by extension 700. The exact input-collection design may vary, but the i and t handlers belong beside the choices they protect.
[menu-context]
exten => 700,1,Answer()
same => n,Background(main-menu)
same => n,WaitExten(10)
; Valid choices
exten => 1,1,Playback(sales)
same => n,Hangup()
exten => 2,1,Playback(support)
same => n,Hangup()
exten => 3,1,Playback(accounts)
same => n,Hangup()
exten => 4,1,Playback(hours)
same => n,Hangup()
exten => 5,1,Playback(operator)
same => n,Hangup()
; Unsupported input
exten => i,1,Playback(pbx-invalid)
same => n,Hangup()
; No input before the response timeout
exten => t,1,Playback(press-button-again)
same => n,Hangup()In this example, WaitExten(10) gives the caller up to 10 seconds to begin entering a choice. If the caller presses an unsupported digit, Asterisk uses i. If the caller presses nothing before the wait expires, Asterisk uses t.
Use audio filenames that exist in the configured Asterisk sounds installation or replace them with your own recordings. A prompt's base name is normally supplied without a file extension.
Reloading the Dialplan
After editing extensions.conf, reload the dialplan using the deployment method appropriate to the installation. A common Asterisk CLI command is:
asterisk -rx "dialplan reload"Verify configuration syntax and confirm that the edited file is the one used by the running Asterisk instance. A reload does not correct a handler placed in the wrong context, so verify the call's actual context as well.
Testing an IVR Error Path
- Test a valid option first. Call the menu extension and enter a known valid digit, such as
1. Confirm that the normal destination or prompt works. - Test invalid input. Call the menu again and enter an unsupported option, such as
6when only1through5are defined. Confirm that theihandler runs, the invalid-selection recording plays, and the call terminates or routes as designed. - Test silence. Call the menu and do not press a key until the response timeout expires. Confirm that the
thandler runs and that the timeout prompt plays. - Check the complete result. Verify that each branch provides the intended audio and either terminates or routes the caller according to the design.
Production Design Considerations
Hangup() is appropriate for a minimal demonstration, but immediately ending every failed interaction is often unfriendly in production. An error branch can play a prompt and return to the menu, route the caller to an operator, or send the caller to voicemail.
When returning to a menu, set a retry limit. Without one, a caller can become trapped in an endless loop caused by repeated invalid entries or timeouts. A retry counter can increment in the i and t branches and route the caller elsewhere after a defined maximum.
Prompts should clearly tell callers what to do. An invalid-input message might say that the selection was not recognized and ask the caller to choose one of the listed options. A timeout message might ask the caller to press a button to continue.
Use consistent behavior across menu contexts. Callers should receive similar explanations, retry rules, and escalation options whether they make an error in the main menu, a language menu, or a submenu.
Troubleshooting
The call disconnects after an unsupported key
- Confirm that an
iextension exists in the active context. - Verify that the handler was not added to a different context from the IVR.
- Check the inbound route and menu entry point to confirm which context the call actually enters.
- Reload the dialplan after making changes.
Silence or unexpected termination occurs when no key is pressed
- Confirm that a
textension exists in the menu context. - Check that the interactive application is actually waiting for input.
- Review the response timeout and any related
TIMEOUT(response)or application settings. - Repeat the test with a timed silent call.
The handler runs but no audio is heard
- Verify that the named sound file is installed and available for the channel's language.
- Test playback of a known working prompt.
- Check for channel, codec, or media-path problems.
- Confirm that the call is answered or that media has been established as required by the surrounding flow.
- Review Asterisk console output during the test call.
A valid option is treated as invalid
- Inspect the active context and confirm that the expected extension exists there.
- Confirm that the caller is entering the digit or sequence represented by the dialplan.
- Check whether an extension pattern or multi-digit collection rule differs from the expected input.
- Use Asterisk dialplan and console diagnostics to trace the executed context and extension.
Exam-Relevant Notes
ihandles invalid or unmatched entered digits in the current context.thandles no input before the response timeout in the current context.- Both special extensions must be defined in the same context as the menu they protect.
- Each extension requires priorities, commonly written with
same => n. - A response timeout occurs before the first digit; a digit timeout can occur between digits in a multi-digit entry.
Playback()plays a prompt, whileHangup()ends the call.