An IVR menu greets callers with recorded prompts and routes them based on their keypad selections — "Press 1 for Sales, Press 2 for Support" — a common first point of contact for business phone systems.
Planning Your IVR Structure
Before building, sketch out the actual call flow — keep menus short (generally no more than 4-5 options) and always include a way to reach a live person, since overly complex IVR trees frustrate callers.
Recording Your Prompts
Record clear, professional audio for each prompt — either using a quality microphone directly, or recording via a phone call into a designated recording extension, then exporting the audio file.
Preparing Audio Files
ffmpeg -i prompt.mp3 -ar 8000 -ac 1 -codec:a pcm_s16le prompt.wav
Asterisk typically expects 8kHz mono WAV audio — convert recordings to this format for compatibility.
Placing Audio Files
sudo cp prompt.wav /var/lib/asterisk/sounds/en/custom/
Building the IVR in FreePBX (Recommended for Most Users)
Under Applications → IVR, create a new IVR: upload your greeting audio, then map each keypress to a destination (extension, ring group, another IVR submenu, or voicemail).
Building the IVR in Raw Asterisk Dialplan
[ivr-main]
exten => s,1,Answer()
exten => s,n,Background(custom/main-greeting)
exten => s,n,WaitExten(10)
exten => 1,1,Goto(internal,1001,1)
exten => 2,1,Goto(internal,1002,1)
exten => 0,1,Goto(internal,1000,1)
exten => t,1,Hangup()
Background plays the prompt while listening for input; WaitExten waits the specified seconds for a keypress before taking the timeout action (t).
Routing Inbound Calls to the IVR
Configure your inbound route (see How to Set Up SIP Trunking for Your PBX) to point incoming calls at your IVR context rather than directly to an extension.
Adding a Timeout and Invalid Entry Handling
exten => t,1,Playback(custom/no-input-goodbye)
exten => t,n,Hangup()
exten => i,1,Playback(custom/invalid-entry)
exten => i,n,Goto(s,1)
t handles timeout (no key pressed), i handles an invalid key press — both should give the caller a clear path forward, not just abruptly hang up.
Setting Up Time-of-Day Routing
Combine your IVR with time conditions (available in FreePBX under Applications → Time Conditions) to route calls differently during and outside business hours — e.g. straight to voicemail overnight.
Testing Thoroughly
Call through every possible menu path yourself before considering the IVR production-ready — a broken option in a rarely-used menu path can go unnoticed for a long time otherwise.
Common Errors
IVR plays but keypresses aren't recognized — verify DTMF (touch-tone) detection settings match your trunk/extension configuration; a mismatch in DTMF mode (RFC2833 vs inband vs SIP INFO) is a common cause.
Continue Reading
- How to Set Up SIP Trunking for Your PBX
- How to Configure Extensions and Voicemail in Asterisk
- How to Install FreePBX on a VPS
Browse more articles in VoIP & Communication Servers.