Asterisk IVR Configuration

So now you have installed Asterisk and now you want to configure IVR(Interactive Voice Response), that's why you have landed here. Incase you are looking for help to install Asterisk you may like to refer this page.

After Asterisk installation, you may find many configuration files available at /etc/asterisk path. In asterisk installation help page, we have explain a bit how to configure endpoints / subscribers in pjsip.conf file.

Now we are going to explain how to configure extensions.conf file for IVR.

  • Configuring single DTMF digit
  • Configuring multiple DTMF digits
Configuring single DTMF digit

Asterisk provides default single DTMF handling configuration as part of installation process with pre-recorded audio files (in english). The pre-recorded files are available at /var/lib/asterisk/sounds/en path. You can provide the customized recorded files if you want. Asterisk uses basic-pbx-ivr-main.gsm pre-recorded file by default.

Let's take an example, extension A wants to call extension B using IVR extension S. The extension number of of A, B and S are 1105, 1106 and 1100 respectively.

Example
A calls to S and receives the pre-recorded audio. A sends DTMF digit 3 (by pressing key 3 in phone keypad) to S, next S calls B. Now A and B can talk to each other.

Asterisk provides this configuration by default to faciliate a basic IVR call. The sample configurations details shown below.

; Exten to dial the main IVR internally.
exten = 1100,1,Verbose(1, "User ${CALLERID(num)} dialed the IVR.")
same = n,Goto(Main-IVR,2565551100,1)


; The IVR script reads “Thank you for calling Super Awesome Company, Waldo’s
; premier provider of perfect products. If you know your party’s extension,
; you may dial it at any time. To establish a sales partnership, press one. To
; speak with a customer advocate, press two. For accounting and other
; receivables, press three. For a company directory, press four. For an
; operator, press zero.”
; demo-congrats is currently used as a placeholder.
[Main-IVR]
exten = 2565551100,1,Verbose(1, "New caller, ${CALLERID(num)} dialed into the IVR.")
  same = n,Answer()
   same = n(start),Background(basic-pbx-ivr-main)
   same = n,WaitExten(10)
   same = n,Background(basic-pbx-ivr-main)
   same = n,Hangup()

exten = 0,1,Verbose(1, "Caller ${CALLERID(num)} dialed the operator.")
   same = n,Goto(Dial-Users,1111,1)
exten = 1,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Sales queue.")
   same = n,Goto(External-Features,2565551200,1)
exten = 2,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Customer Experience queue.")
   same = n,Goto(External-Features,2565551250,1)
exten = 3,1,Verbose(1, "Caller ${CALLERID(num)} dialed Accounting and Receivables.")
   same = n,Goto(Dial-Users,1106,1)
exten = 4,1,Verbose(1, "Caller ${CALLERID(num)} dialed the directory.")
   same = n,Directory(example,Dial-Users)

exten = i,1,Playback(option-is-invalid)
   same = n,Goto(2565551100,start)

exten = t,1,Playback(are-you-still-there)
   same = n,Goto(2565551100,start)

When A will call to S(i.e. 1100) extension, it will invoke Main-IVR block and play the basic-pbx-ivr-main audio. When A pressed three(DTMF digit), S will dial to B(i.e.1106). Then A and B can talk to each other.

Configuring multiple DTMF digits

Again let's take an example, extension A wants to call extension B using IVR extension S. The extension number of A, B and S are 1105, 1106 and 1100 respectively.

Various stages in this IVR based call are -

  • A calls Asterisk PBX. A receives pre-recorded audio. Let's name it IVR session 1.
  • A sends DTMF digit 0 to Asterisk PBX, PBX plays a pre-recorded audio. Let's name it IVR session 2.
  • A sends DTMF digit 1 to Asterisk PBX, PBX plays a pre-recorded audio. Let's name it IVR session 3.
  • A sends DTMF digit 3 to Asterisk PBX, PBX stops audio prompt. Initiates call to extension B.
  • Next A and B are in call.

    For IVR session 1, 2 and 3, you can use same pre-recorded audio file or different pre-recorded audio files. In this example, same pre-recorded audio file is used.

    Example
    A calls to S and receives the pre-recorded audio (IVR Session 1). Next A sends DTMF digit 0, receives pre-recorded audio (IVR Session 2). Next A sends DTMF digit 1, receives pre-recorded audio (IVR Session 3). Next A sends DTMF digit 3, call gets connected to B. The sample configuration details shown below.

    ; Exten to dial the main IVR internally.
    exten = 1100,1,Verbose(1, "User ${CALLERID(num)} dialed the IVR.")
    same = n,Goto(Main-IVR,2565551100,1)


    ; The IVR script reads “Thank you for calling Super Awesome Company, Waldo’s
    ; premier provider of perfect products. If you know your party’s extension,
    ; you may dial it at any time. To establish a sales partnership, press one. To
    ; speak with a customer advocate, press two. For accounting and other
    ; receivables, press three. For a company directory, press four. For an
    ; operator, press zero.”
    ; demo-congrats is currently used as a placeholder.
    [Main-IVR]
    exten = 2565551100,1,Verbose(1, "New caller, ${CALLERID(num)} dialed into the IVR.")
      same = n,Answer()
       same = n(start),Background(basic-pbx-ivr-main)
       same = n,WaitExten(10)
       same = n,Background(basic-pbx-ivr-main)
       same = n,Hangup()

    exten = 0,1,Verbose(1, "Caller ${CALLERID(num)} dialed the operator.")
       same = n,Goto(IVR2,2565551100,1)
    exten = 1,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Sales queue.")
       same = n,Goto(External-Features,2565551200,1)
    exten = 2,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Customer Experience queue.")
       same = n,Goto(External-Features,2565551250,1)
    exten = 3,1,Verbose(1, "Caller ${CALLERID(num)} dialed Accounting and Receivables.")
       same = n,Goto(Dial-Users,1107,1)
    exten = 4,1,Verbose(1, "Caller ${CALLERID(num)} dialed the directory.")
       same = n,Directory(example,Dial-Users)

    exten = i,1,Playback(option-is-invalid)
       same = n,Goto(2565551100,start)

    exten = t,1,Playback(are-you-still-there)
       same = n,Goto(2565551100,start)


    [IVR2]
    exten = 2565551100,1,Verbose(1, "New caller, ${CALLERID(num)} dialed into the IVR.")
      same = n,Answer()
       same = n(start),Background(basic-pbx-ivr-main)
       same = n,WaitExten(10)
       same = n,Background(basic-pbx-ivr-main)
       same = n,Hangup()

    exten = 0,1,Verbose(1, "Caller ${CALLERID(num)} dialed the operator.")
       same = n,Goto(Dial-Users,1111,1)
    exten = 1,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Sales queue.")
       same = n,Goto(IVR3,2565551100,1)
    exten = 2,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Customer Experience queue.")
       same = n,Goto(External-Features,2565551250,1)
    exten = 3,1,Verbose(1, "Caller ${CALLERID(num)} dialed Accounting and Receivables.")
       same = n,Goto(Dial-Users,1106,1)
    exten = 4,1,Verbose(1, "Caller ${CALLERID(num)} dialed the directory.")
       same = n,Directory(example,Dial-Users)

    exten = i,1,Playback(option-is-invalid)
       same = n,Goto(2565551100,start)

    exten = t,1,Playback(are-you-still-there)
       same = n,Goto(2565551100,start)


    [IVR3]
    exten = 2565551100,1,Verbose(1, "New caller, ${CALLERID(num)} dialed into the IVR.")
      same = n,Answer()
       same = n(start),Background(basic-pbx-ivr-main)
       same = n,WaitExten(10)
       same = n,Background(basic-pbx-ivr-main)
       same = n,Hangup()

    exten = 0,1,Verbose(1, "Caller ${CALLERID(num)} dialed the operator.")
       same = n,Goto(Dial-Users,1111,1)
    exten = 1,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Sales queue.")
       same = n,Goto(External-Features,2565551200,1)
    exten = 2,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Customer Experience queue.")
       same = n,Goto(External-Features,2565551250,1)
    exten = 3,1,Verbose(1, "Caller ${CALLERID(num)} dialed Accounting and Receivables.")
       same = n,Goto(Dial-Users,1106,1)
    exten = 4,1,Verbose(1, "Caller ${CALLERID(num)} dialed the directory.")
       same = n,Directory(example,Dial-Users)

    exten = i,1,Playback(option-is-invalid)
       same = n,Goto(2565551100,start)

    exten = t,1,Playback(are-you-still-there)
       same = n,Goto(2565551100,start)

    When A(i.e. 1105) calls to S(i.e. 1100) extension, Asterisk invokes Main-IVR block and play the basic-pbx-ivr-main audio (IVR Session 1). Next when A sends DTMF digit 0, Asterisk invokes IVR2 block (IVR Session 2). Next when A sends DTMF digit 1, Asterisk invokes IVR3 (IVR Session 3). Next wehn A sends DTMF digit 3, call connects to B(i.e. 1106) extension.

Tag: 
Asterisk, PBX, Configuration, IVR