How to create basic IVR on Asterisk on Oracle Linux 9.3

To Create Basic IVR On Asterisk On Oracle Linux 9.3

Introduction

IVR, which stands for Interactive Voice Response, is a technology that streamlines customer service interactions by allowing callers to interact using touch-tone digits or their voice. A basic example of an IVR application is an automated attendant or voice menu: callers are presented with a recorded menu and respond by selecting a digit or, in some cases, by entering an extension number.

Procedure Steps

Step 1: Check the OS version by using the below command

[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3

Step 2: Check the status of the Asterisk by using the below command

[root@linuxhelp ~]# systemctl status asterisk.service
● asterisk.service - LSB: Asterisk PBX
     Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
     Active: active (running) since Thu 2024-05-09 16:08:17 IST; 1h 5min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 6428 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
   Main PID: 6458 (asterisk)
      Tasks: 44 (limit: 21739)
     Memory: 42.5M
        CPU: 41.152s
     CGroup: /system.slice/asterisk.service
             ├─6456 /bin/sh /usr/sbin/safe_asterisk
             └─6458 /usr/sbin/asterisk -f -vvvg -c

May 09 16:08:17 linuxhelp systemd[1]: Starting LSB: Asterisk PBX...
May 09 16:08:17 linuxhelp asterisk[6428]: Starting asterisk:
May 09 16:08:17 linuxhelp systemd[1]: asterisk.service: Can't open PID file /run/asterisk/asterisk.pid (yet?) after start: Operation not permitted
May 09 16:08:17 linuxhelp systemd[1]: asterisk.service: Supervising process 6458 which is not our child. We'll most likely not notice when it exits.
May 09 16:08:17 linuxhelp systemd[1]: Started LSB: Asterisk PBX.

Step 3: Move to the Asterisk directory by using the below command

[root@linuxhelp ~]# cd /etc/asterisk/
[root@linuxhelp asterisk]#

Step 4: Edit the extensions.conf file to add IVR by using the below command

[root@linuxhelp asterisk]# vim extensions.conf
Add the following lines
[internal]
exten => 167,1,Background(pls-wait-connect-call)
exten => 167,n,Goto(test,s,1)

[test]
exten => s,1,Answer()
 same => n,Background(press-1&press-2)
 same => n,WaitExten()

exten => 1,1,Playback(you-entered)
 same => n,SayNumber(${EXTEN})
 same => n,Dial(PJSIP/167,20)
 same => n,Hangup()

exten => 2,1,Playback(you-entered)
 same => n,SayNumber(${EXTEN})
 same => n,Dial(PJSIP/167,20)
 same => n,Hangup()

exten => i,1,Playback(option-is-invalid)

Step 5: Login to the Asterisk CLI mode by using the below command

[root@linuxhelp asterisk]# asterisk -rvvvvvvvvvvvvvvvvvv
Asterisk 20.5.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.5.0 currently running on linuxhelp (pid = 6458)
linuxhelp*CLI>

Step 6: Reload the dialplan by using the below command

linuxhelp*CLI> dialplan reload
Dialplan reloaded.
    -- Time to scan old dialplan and merge leftovers back into the new: 0.000086 sec
    -- Time to restore hints and swap in new dialplan: 0.000009 sec
    -- Time to delete the old dialplan: 0.000018 sec
    -- Total time merge_contexts_delete: 0.000113 sec
    -- pbx_config successfully loaded 2 contexts (enable debug for details).

Step 7: Now make call for 168 to 167 to check the IVR by using Zoiper and Microsip software

Step 8: Now make call from 168 to 167 and now press 1 the call is working fine

Snap 9: Again to make call from 168 to 167 and now press 2 the call is working fine

Step 10: Output for Press 1

Executing [167@internal:1] BackGround("PJSIP/168-00000003", "pls-wait-connect-call") in new stack
       > 0x7f91bc0725f0 -- Strict RTP learning after remote address set to: 192.168.6.102:4008
    -- <PJSIP/168-00000003> Playing 'pls-wait-connect-call.ulaw' (language 'en')
       > 0x7f91bc0725f0 -- Strict RTP learning after remote address set to: 192.168.6.102:4008
       > 0x7f91bc0725f0 -- Strict RTP switching to RTP target address 192.168.6.102:4008 as source
    -- Executing [167@internal:2] Goto("PJSIP/168-00000003", "test,s,1") in new stack
    -- Goto (test,s,1)
    -- Executing [s@test:1] Answer("PJSIP/168-00000003", "") in new stack
    -- Executing [s@test:2] BackGround("PJSIP/168-00000003", "press-1&press-2") in new stack
    -- <PJSIP/168-00000003> Playing 'press-1.ulaw' (language 'en')
    -- <PJSIP/168-00000003> Playing 'press-2.ulaw' (language 'en')
    -- Executing [s@test:3] WaitExten("PJSIP/168-00000003", "") in new stack
       > 0x7f91bc0725f0 -- Strict RTP learning complete - Locking on source address 192.168.6.102:4008
    -- Executing [1@test:1] Playback("PJSIP/168-00000003", "you-entered") in new stack
    -- <PJSIP/168-00000003> Playing 'you-entered.ulaw' (language 'en')
    -- Executing [1@test:2] SayNumber("PJSIP/168-00000003", "1") in new stack
    -- <PJSIP/168-00000003> Playing 'digits/1.ulaw' (language 'en')
    -- Executing [1@test:3] Dial("PJSIP/168-00000003", "PJSIP/167,20") in new stack
    -- Called PJSIP/167
    -- PJSIP/167-00000004 is ringing
  == Everyone is busy/congested at this time (1:1/0/0)
    -- Executing [1@test:4] Hangup("PJSIP/168-00000003", "") in new stack
  == Spawn extension (test, 1, 4) exited non-zero on 'PJSIP/168-00000003'

Step 11: Output for Press 2

Executing [167@internal:1] BackGround("PJSIP/168-00000005", "pls-wait-connect-call") in new stack
       > 0x7f91bc07c140 -- Strict RTP learning after remote address set to: 192.168.6.102:4012
    -- <PJSIP/168-00000005> Playing 'pls-wait-connect-call.ulaw' (language 'en')
       > 0x7f91bc07c140 -- Strict RTP learning after remote address set to: 192.168.6.102:4012
       > 0x7f91bc07c140 -- Strict RTP switching to RTP target address 192.168.6.102:4012 as source
    -- Executing [167@internal:2] Goto("PJSIP/168-00000005", "test,s,1") in new stack
    -- Goto (test,s,1)
    -- Executing [s@test:1] Answer("PJSIP/168-00000005", "") in new stack
    -- Executing [s@test:2] BackGround("PJSIP/168-00000005", "press-1&press-2") in new stack
    -- <PJSIP/168-00000005> Playing 'press-1.ulaw' (language 'en')
    -- <PJSIP/168-00000005> Playing 'press-2.ulaw' (language 'en')
    -- Executing [s@test:3] WaitExten("PJSIP/168-00000005", "") in new stack
       > 0x7f91bc07c140 -- Strict RTP learning complete - Locking on source address 192.168.6.102:4012
    -- Executing [2@test:1] Playback("PJSIP/168-00000005", "you-entered") in new stack
    -- <PJSIP/168-00000005> Playing 'you-entered.ulaw' (language 'en')
    -- Executing [2@test:2] SayNumber("PJSIP/168-00000005", "2") in new stack
    -- <PJSIP/168-00000005> Playing 'digits/2.ulaw' (language 'en')
    -- Executing [2@test:3] Dial("PJSIP/168-00000005", "PJSIP/167,20") in new stack
    -- Called PJSIP/167
    -- PJSIP/167-00000006 is ringing
  == Everyone is busy/congested at this time (1:1/0/0)
    -- Executing [2@test:4] Hangup("PJSIP/168-00000005", "") in new stack
  == Spawn extension (test, 2, 4) exited non-zero on 'PJSIP/168-00000005'

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps to create a basic IVR on Asterisk on Oracle Linux 9.3. Your feedback is much welcome

FAQ
Q
How many options should an IVR have?
A
Five Options in IVR on Asterisk
Q
How many types of IVR are there?
A
The two basic types of IVR services are inbound and outbound.
Q
What is the use of the IVR?
A
An IVR application is an automated attendant or voice menu: callers are presented with a recorded menu and respond by selecting a digit or, in some cases, by entering an extension number.
Q
What is Asterisk IVR?
A
A technology that automates routine customer service interactions by allowing callers to interact using touch-tone digits or their voice.
Q
What is an abbreviation of IVR in an Asterisk?
A
IVR stands for Interactive Voice Response