Creating an IVR


I have little experiencing in creating IVR’s in Asterisk, in fact this is my first. But I need to create a simple IVR that allows a caller to press 1 to be diverted to ext 200 or press to for voicemail.

So far I have

exten => xxx,1,goto(NewIVR)

exten => n,1,Wait(15)
exten => n,2,Answer()
exten => n,2,Background(Dutch-IVR1)
exten => n,3,hangup()

exten => 1,1,goto(extxxx)
exten => 2,1,goto(voicemail)

I want to try and get the syntax right before I start editing the extensions.conf file, Does this look right? or am I missing something?


There really is TONS of documentation on this on the internet. Also try using the Search button on the forum. … s+ivr+menu

If you do not want to do the work yourself, don’t expect that the forum members will do it for you. Some questions are just too trivial and have been answered a 1000 times already.

Indeed there is and I had already read this document which lead me to try and get some feedback on my solution. It seems I came to the wrong place so I apologise for being “trivial”.

This being my first attempt at setting up and IVR along with limited experience in Asterisk I merely wanted confirmation that I was heading in the right direction as I have read a number of different docs using varying syntax. Either way thanks for your help in pointing out my duplicated posting and trivia, rest assured it won’t happen again…


You have two step 2’s for extension n. There seems no mechanism to reach extension n. Goto with a single parameter expects a named “priority”, but you seem to be trying to match it with contexts.

There are several basic syntactical errors in your proposed script. You must have a basic understanding of the format of the dial plan language.

You have the definition of the [NewIVR] context header correct.
The individual lines that define the extension steps is incorrect for the main body of the IVR.

The format for each step is…

exten => ,,

therefore, instead of ‘exten => n,1,Wait()’ you should have something like… ‘exten => ivrmenu,1,Wait(1)’ (I really do not think you want the caller to wait 15 seconds before answering the call).

Subsequent lines for that same extension should have increasing priority numbers. These priority numbers define the order in which actions are taken. Remember, dial plan is just a script. So, the second step could be ‘exten => ivrmenu,n,Answer()’

The key to the ‘I’ in IVR is interaction with the called. The Background() and WaitExten() calls will get DTMF input from the caller, and if valid, send the caller to the appropriate extension within the same context (NewIVR). You definitely want to read up on those applications. (core show application Background)

Also, your goto() call can take multiple arguments. When a single argument is passed, it is used as a priority, or priority label. In you example, it is looking for a priority within the current context and extension. It would not find what you are looking for. You need a call like goto(NewIVR,ivrmenu,1) in order for the goto do do what you want.

That is a start.

I highly recommend you check out the Asterisk book (


Thanks for the replies guys. They have been a great help…
I had rewrote the context after noticing my errors and reading a few other articles to a point where it worked, mostly, as options 1 and 2 worked but it would play the correct message:

exten => xxx,1,Goto(New-IVR,s,1)

exten => s,1,Answer
exten => s,2,Background(9techbusy)
exten => s,3,Background(beep)
exten => s,4,ResponseTimeout,10
exten => 1,1,Queue(sqlq)
exten => 2,1,Queue(officeq)
exten => 3,1,Goto(mainext,180)
exten => t,1,Goto(#,1)
exten => i,1,Playback(invalid)

This answered the phone and played the ‘invalid’ message, however I was able to press 1 and get the sqlq and press 2 to get the officeq. So it worked in part…I realise that setting exten => i,1,Playback(invalid) as priority 1 would have caused the message playback incorrectly.

Now I have a few more tools to use I should be able to complete the task…Once again thanks for the help


After reading the manual i have got this to work:

exten => bvivr,1,Wait(2)
exten => bvivr,2,Answer()
exten => bvivr,3,Background(9techbusy)
exten => bvivr,4,Background(beep)
exten => bvivr,WaitExten(5)
exten => 1,1,Queue(sqlq)
exten => 2,1,Queue(officeq)
exten => 3,1,Voicemail(u180)
exten => i,1,Playback(invalid)
exten => bvivr,Hangup()

if I use same => n,etc nothing happens so maybe our version of asterisk does not recognise this snytax.
However I wanted to put a timeout message in such as

exten =>t,1,playback(goodbye) ; after the exten =>i,1,playback(invalid) line
When I do this the IVR part works ok but the call just doesn’t hangup or go anywhere else. I am sure it’s a syntax thing again…But still learning…


The same => syntax is available starting in version 1.8 of Asterisk and above.

It looks like you are pretty close, but it does sometimes take a bit to get used to, so let me offer some suggestions.

In your last code posting, you have the last line of bvivr. This is after you have also has other extensions defined. This is incorrect. Also, that same line and the WaitExten(5) line have no priority. They probably are not even included in the code when Asterisk loads (or reloads) the dialplan code.

There is also another extension you should consider, the ‘h’ extension for hangup.

I like to have a single Hangup() call for an IVR context. Each extension should also always make it to a Hangup(). For instance, if the queue is empty, depending on the configuration of the queue in queues.conf, the call will likely continue on in the dial plan at the next priority In you example, there is not next priority. Asterisk usually hangs up at that point, but I consider that messy.

Let me offer some adjustments to your code.

exten => bvivr,1,Wait(2)
exten => bvivr,n,Answer()
exten => bvivr,n,Background(9techbusy)
exten => bvivr,n,Background(beep)
exten => bvivr,n,WaitExten(5)

exten => 1,1,Queue(sqlq)
exten => 1,n,Goto(noagent,1)

exten => 2,1,Queue(officeq)
exten => 2,n,Goto(noagent,1)

exten => 3,1,Voicemail(u180)
exten => 3,n,Goto(h,1)

exten => i,1,Playback(invalid)
exten => i,n,Goto(h,1)

exten => t,1,Playback(invalid)
exten => t,n,Goto(h,1)

exten => noagent,1,NoOP(No Agent Available)
exten => noagent,n,Playback(were-sorry&nbdy-avail-to-take-call)
exten => noagent,n,Goto(h,1)

exten => h,1,NoOp(Goodbye)
exten => h,n,Playback(goodbye)
exten => h,n,Hangup()

Note how if the call is unable to enter the queue, it goes to an extension (noagent) and plays a message before going to the hangup extension which hangs up the call.

The ‘i’ and ‘t’ extensions do the same thing, but they do not have to. There is a new ‘e’ extension that is a catchall for ‘i’, ‘t’ and ‘T’, but I have never used it. Old school I guess.

Note also that the WaitExten() is the last priority in the bvivr extension. I have found that having any priorities after that can cause unusual experiences. Anywho, if the user dials a correct extension, it will jump there. If they time out or enter an invalid extension, it will jump there so no priority, in the same extension, after WaitExten() is required.

I hope that helps.

Have fun.