How to create IVR in Asterisk

pawanopensource used Ask the Experts™
i had created a pbx using sangoma usb fxo. i want to create my own ivr in that pbx how to that.

these are my ivr extensions,

101 -  reception
102 -  director
103 - sales
104 - accounts

i want when a call comes caller should hear company ivr. plz guide me in that.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Luis Clara FernandesBusiness Analyst
You must crate a context in your extensions.conf file. The context will look as following.
I hope it helps.
Luis C. C. Fernandes

exten=>s,n,WaitExten(5) ; TIME TO WAIT FOR DIGITS







exten=>i,1,NoOp("Sucks, Error Invalid")

Open in new window


thx a lot clarfer,
thx a lot for putting so much efforts. well i want to record my own voice n make my own ivr how to do that.
Top Expert 2010

Yes you can record your own voice , but it depends on what format will work on your application or what you are using. We use shift8admin and our recording format is .wav 8khz mono format.

Once you have done that , you can go to web gui  and upload a new file into your inbound routes.

What do you use trixbox? or something else?
Most Valuable Expert 2012

To Create an IVR:

1. Create the recording.

I recommend that you create a config context in which you can store your recording utility extensions among other things. For example:

exten => *01,1,Record(biz-ivr.wav)
exten => *02,1,Playback(biz-ivr)

Then, you can keep these configurations in one context, nice and clean. Easy to update, easy to manage.

Then just use the include statement to include the configs in the context where you have your phones ([default] if you haven't changed anything). My extensions are kept in [local_stations].

;This is the business stuff
include => config

exten => _10X,1,Dial(${EXTEN})

Next, create the context where the ivr will live.

exten = s,1,Answer()
exten = s,n,Wait(1)
exten = s,n,Background(biz-ivr)
exten = s,n,WaitExten(10)
exten = i,1,Goto(s,1)
exten = t,1,Goto(s,1)

There are some VERY important extensions here that you need to be aware of.

i is for invalid extension. If someone dials the wrong thing, i will fire.

t is for timeout. If they wait to long, t fires.

Answer picks up the line, and Wait gives it 1 second to let the call get setup so you can hear the entire IVR. If you skip this step, the frist word will usually get cut off.

WaitExten allows people 10 seconds to make their choice.

Background plays the recording. There is also a Playback() application, but it only plays recordings. It doesn't listen for DTMF when someone chooses a menu option. Use Background.

So you can see from this part of the context, if you make a mistake, wait to long, or don't make a choice, it goes back to the top and plays the IVR again. This is important because Asterisk will just drop the call otherwise.

After that part of the context, you can choose your menu items. It is important to note here taht if you are allowing people to dial an extension directly from the menu, then you cannot have a menu option #1.


Because if you have a menu option #1, Asterisk will wait the requisite 5 seconds or so for it to time out before it fires the exten => 1 part of the context. It will see if you want menu option #1 or are you about to dial extension 101.

So, since your extensions are 10X, your menu options should start at 2. This gives instant response.

Here are some example menu items:

exten = 1,1,Queue(business,W,,,20)
exten = 1,n,Voicemail(8560,b)

exten = 2,1,Queue(business,rW,,,20)
exten = 2,n,Voicemail(8560,b)

exten = 3,1,MeetMe(263)

exten = 4,1,Voicemail(8561,b)

Lastly, you need to setup your inbound extension to refer all calls to the menu IVR. You can do this with:

exten =>  _X.,1,Goto(business,s,1)

This will definatley work, but is not a best practice because it matches EVERYTHING. It would be better to isolate it using channels or DIDs, but since you do not have a complicated setup, it should do the trick.

Post back if you have any questions.


thx santosh,
for replying. i had configured asterisk. for r/d purpose i had made pbx in my machine using sangoma fxo.
every thing working fine. as i am going depper i am getting to know new things. so this time is for IVR. can i made ivr as v use in bank,

when a customer got his new ATM/Credit card he is adviced to register first with the bank and so on.

is asterisk able to handle ivr for banks ?


dear santosh,

can u explain me what is shift8admin is and whats the use in asterisk.

ill be really thankfull to u for ur kind support n guidance.



Dr Dammit,

can u tell me what is shift8admin in linux and why it is used.

Most Valuable Expert 2012

Shift8 ( looks like another GUI for Asterisk similar to Trixbox, AsteriskNOW, and others.

It is used for people who cannot / do not want to learn to run asterisk from config files, and who need a GUI to operate it.

To answer your other question, yes, Asterisk can handle bank IVRs.

Please note, if you need to access a database (like for a bank IVR) Shift8, Trixbox, AsteriskNOW all become bad solutions. You need regular asterisk customized so that it can access databases via ODBC.
Luis Clara FernandesBusiness Analyst

Still need help?
Luis C.C. Fernandes
Top Expert 2010

Sorry Pawanopensource ,

I have been away for a while, Basically shift8admin is similar to trixbox .

It is just a GUI for all configurations. Trust me its worst then trixbox. So stay away from it.

Basically all these GUI's are for managers who want just a view like who is logged in, or how many calls are ina queue.

Most of programmers dont use GUI for configuration.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial