Basic IVR Menu

IVR -- Last reviewed 2026-06-13 dtmf ivr beginner Found this useful? Upvote it. ×

Basic IVR Menu

A simple auto-attendant that plays a greeting and routes callers based on their keypress input.

Requirements

Dialplan

[ivr-main]
exten => s,1,Answer()
 same => n,Set(TIMEOUT(response)=5)
 same => n,Set(TIMEOUT(digit)=3)
 same => n(loop),Background(custom/welcome)
 same => n,WaitExten()

; Caller pressed 1 -- Sales
exten => 1,1,Goto(sales,s,1)

; Caller pressed 2 -- Support
exten => 2,1,Goto(support,s,1)

; Caller pressed 0 -- Operator
exten => 0,1,Goto(operator,s,1)

; Invalid input
exten => i,1,Playback(pbx-invalid)
 same => n,Goto(s,loop)

; Timeout -- no input
exten => t,1,Playback(vm-goodbye)
 same => n,Hangup()

How it works

  1. Answer and set timeouts: TIMEOUT(response) sets how long WaitExten() waits for a digit when called without an explicit argument. TIMEOUT(digit) sets the inter-digit timeout for multi-digit extensions. Defining both at the top means you only need to change them in one place, even across a multi-level menu.
  2. Background(): Plays the audio file while listening for DTMF. This is the key difference from Playback(), which ignores keypresses.
  3. WaitExten(): Waits for input after Background() finishes, using the TIMEOUT(response) value set above.
  4. Extension matching: Each DTMF digit is matched as an extension in the current context. Extensions i (invalid) and t (timeout) are special handlers.

Tips

User Notes

Know a tip or gotcha for this topic? Share it below and help others.

Contribute a note

Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.

Moderated before publishing. Email never shown.
Related Snippets