IVR in the dialplan

Create a new context in the dialplan for the IVR. If you do plan on having more that one IVR it will be a good idea to create separate IVRs. In this course we will use just one IVR.

In the new context we can start the first extension with the letter “s” to indicate it being the starting point of the IVR. We have a choice of a few applications to play the main greeting audio file. If we use the Playback() application that we have used in past lessons the user must wait until the audio file has completed until pressing their option. We could also use the Background() application to the play the audio, allowing the user to press their option at any time.

A new application WaitExten() can be used to retrieve the selected option from the user. Within the parenthesis we can set the number of seconds the system should wait for a selection.

Below is an example of creating a new context for the IVR with a starting extension:

[ivr]
exten => s,1,NoOp(Main IVR)
same => n,Answer
same => n, Background(ivr/main_menu)
same => n,WaitExten(5)

We gave the user the option to press 0 for the operator. We can decide which extension from the [phones] context will be the operator. I will use extension 100. Using the Goto() application I will send direct the call from the [ivr] context to the [phones] context. Add the following extension in the [ivr] context.

exten => 0,1,NoOp(Pressed 0)
same => n,Goto(phones,100,1)
same => n,Hangup

Now it is time to program what happens when options 1 – 4 are selected. We will begin with option number 1 which allows the user to enter in the 3 digit extension of the user they are calling. To do this will we need to use a new application called Read().

The Read() application takes three parameters that we will want to use. The first is the variable that will hold the numbers entered by the user. The second is the sound that plays to inform the user of their needed actions. The third parameter can be use to limit the amount of digits the user can enter.

Once we get the extension that the user wishes to be transferred to, we will use that variable to dial the extension in the [phones] context. To create the extension for option 1, use the following code:

exten => 1,1,NoOp(Pressed 1)
same => n,Read(PartyExt,ivr/party_extension,3)
same => n,Goto(phones,${PartyExt},1)
same => n,Hangup

From the main IRV menu, option number 2 is used to call the techteam queue. We can simply use the Goto() application to call extension 300 in the [phones] context (setup in a previous lesson). Use the code below:

exten => 2,1,NoOp(Pressed 2)
same => n,Goto(phones,300,1)
same => n,Hangup

Option 3 will simply playback the an audio recording indicating the business hours of the company. We will create the new extension and playback the audio file.

exten => 3,1,NoOp(Pressed 3)
same => n,Playback(ivr/business_hours)
same => n,Hangup

Option 4 gives the user a chance to repeat the main menu. We can use the Goto() application to send the user back to extension “s” in the [ivr] context.

exten => 4,1,NoOp(Pressed 4)
same => n,Goto(ivr,s,1)
same => n,Hangup