VMware ESXi and vSphere Cluster Management
Create a Simple Automated Attendant in Asterisk
Learn how to build an Asterisk automated attendant with greeting and menu prompts, DTMF routing, SIP destinations, and no-input timeout handling.
What an Automated Attendant Does
An automated attendant is a telephone menu that directs callers using keypad choices. It is an IVR, or Interactive Voice Response, entry point: callers hear recorded instructions, press a DTMF key, and are sent to a person or department.
In this example, a caller reaches extension 800, hears a greeting, receives a menu, and chooses Sales, Marketing, or the operator. If the caller does not press a key within the allowed time, Asterisk sends the call to the operator automatically.
| Stage | Asterisk application or extension | Caller experience | Result |
|---|---|---|---|
| Menu entry | Extension 800 | The call enters the attendant. | Asterisk starts the menu sequence. |
| Greeting prompt | Playback(our-greeting) | The caller hears an introductory message. | The greeting finishes before the choices are presented. |
| Menu prompt | Background(main-menu) | The caller hears the available keys. | DTMF input can be matched to menu extensions. |
| Digit 1 | Extension 1 | The caller selects Sales. | Asterisk dials Alice. |
| Digit 2 | Extension 2 | The caller selects Marketing. | Asterisk dials Bob. |
| Digit 0 | Extension 0 | The caller selects the operator. | Asterisk dials George. |
| No input timeout | Special t extension | The caller makes no selection. | Asterisk logs the timeout and sends the call to George. |
Dialplan Structure and Menu Entry
The Asterisk dialplan is the rule set that controls how calls are handled. A common file for these rules is extensions.conf. A dialplan extension is a dialable number or input pattern with instructions attached to it. In this menu, extension 800 is the entry point.
Dialplan instructions execute in priorities, which are ordered steps. The first step uses priority 1. The shorthand same => n means “continue with the next available priority for the current extension.”
Menu choices must be defined in the same dialplan context as extension 800 unless the dialplan explicitly routes to another context. A context is the named section, such as [from-internal], that contains related extensions.
Prepare Prompts and Endpoints
- Make sure the greeting recording named
our-greetingand the menu recording namedmain-menuexist in an Asterisk-configured sounds location. - Use an audio format supported by the installed Asterisk channel and codec configuration.
- Reference prompt names without an audio filename extension. For example, use
Playback(our-greeting), not a filename with.wavor another suffix. - Configure and register reachable SIP endpoints for Alice, Bob, and George. The example uses the legacy SIP device targets
SIP/alice,SIP/bob, andSIP/george. - Recording or installing custom Asterisk prompts is a prerequisite when these example recordings do not already exist.
Build the Three-Option Menu
Add the following logic to the appropriate context in extensions.conf. The context name shown here is an example; use the context through which callers should access extension 800.
[from-internal]
exten => 800,1,Playback(our-greeting)
same => n,Background(main-menu)
same => n,WaitExten(4)
same => n,Goto(0,1)
exten => 1,1,Verbose(2,Caller selected 1)
same => n,Dial(SIP/alice)
exten => 2,1,Verbose(2,Caller selected 2)
same => n,Dial(SIP/bob)
exten => 0,1,Verbose(2,Caller selected 0)
same => n,Dial(SIP/george)
exten => t,1,Verbose(1,Caller ${CALLERID(all)} timed out)
same => n,Goto(0,1)How the Prompt Sequence Works
Playback plays audio that should simply play. The greeting uses it so the introduction completes before the menu interaction begins.
Background plays audio while permitting DTMF-driven extension matching. The menu recording should tell callers which keys are available, such as “Press 1 for Sales, 2 for Marketing, or 0 for the operator.”
WaitExten(4) then gives the caller a four-second input window. When a DTMF digit is received, Asterisk attempts to match it to an extension in the current context. A pressed 1 therefore routes to extension 1, a pressed 2 routes to extension 2, and a pressed 0 routes to extension 0.
How the Options Route Calls
| Key pressed | Business destination | Dial target | Dialplan action |
|---|---|---|---|
| 1 | Sales / Alice | SIP/alice | Log the selection, then run Dial. |
| 2 | Marketing / Bob | SIP/bob | Log the selection, then run Dial. |
| 0 | Operator / George | SIP/george | Log the selection, then run Dial. |
| No input | Operator fallback | SIP/george | Run the timeout extension, then jump to extension 0, priority 1. |
Dial calls a device or destination. In this example, the device targets use SIP, the Session Initiation Protocol. Verbose writes a diagnostic message at the selected verbosity level, making the caller's choice visible in the Asterisk console or log output.
Handling No Response
The special t extension is the timeout handler. Asterisk uses it when the caller does not provide input before the input timer expires.
This handler logs the caller identity using ${CALLERID(all)}, then executes Goto(0,1). Goto transfers dialplan processing to a specified extension and priority: in this case, extension 0, priority 1. The call consequently follows the operator path and dials George.
The explicit same => n,Goto(0,1) after WaitExten(4) is also a fallback in the sequential flow. The special t extension is the normal timeout route when Asterisk handles the wait as an extension timeout. Keeping both paths pointed at option 0 makes the intended operator fallback clear.
Apply and Test the Dialplan
- Save the changes to
extensions.conf. - Reload the dialplan from the operating system shell:
asterisk -rx "dialplan reload" - Call extension
800. - Confirm that the greeting plays, followed by the menu prompt.
- Press
1and verify that Alice's SIP endpoint rings. - Repeat with
2for Bob and0for George. - Call extension 800 again and allow the four-second input window to expire. Confirm that the timeout is logged and George rings.
- Review the Asterisk console or log output to confirm each selected path and the timeout path.
Troubleshooting
The Menu Audio Is Not Heard
- Verify that the recording names match
our-greetingandmain-menu. - Confirm that the files are in an Asterisk-configured sounds directory.
- Check that the audio format is supported by the channel.
- Test each recording with a simple
Playbackstep.
A Key Does Not Reach a Destination
- Confirm that extensions
0,1, and2are defined in the active menu context. - Reload the dialplan after editing the file.
- Use console verbosity and test calls to determine whether DTMF is being received.
- Check that the endpoint or trunk is transmitting DTMF correctly.
The Selected Employee Does Not Ring
- Verify that the SIP endpoint is registered and reachable.
- Compare
SIP/alice,SIP/bob, andSIP/georgewith the configured device identifiers. - Check whether the device is busy, unavailable, or restricted by endpoint configuration.
- Review the
Dialoutput in the Asterisk console.
No-Input Callers Do Not Reach the Operator
- Confirm that the
textension is present in the same context. - Wait longer than the configured four-second period during testing.
- Test option
0directly before testing the timeout path. - Verify that
Goto(0,1)points to the operator extension and its first priority.
Next Steps
This basic attendant can be expanded with an i extension for invalid keys, nested menus, time conditions, queues, inbound route contexts, and more detailed caller-ID diagnostics. For this implementation, the complete call path is extension 800 to a prompt, then a DTMF choice to Alice, Bob, or George, with no response escalating to George.