How to use Asterisk Goto and GotoIf application on Debian 12
To Use Asterisk Goto And GotoIf Application On Debian 12
Introduction:
Goto allows jumping to a specific context, extension, or priority, while GotoIf enables conditional branching based on certain conditions, providing flexibility in call routing.
Procedure:
Step 1: Check the OS version by using the below command.
root@linuxhelp:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL=https://bugs.debian.org/
Step 2: Go to Following Location by using the below command.
root@linuxhelp:~# cd /etc/asterisk
Step 3: Open and Check extensions.conf file for dialplan configuration by using the below command.
root@linuxhelp:/etc/asterisk# vim extensions.conf
[internal]
exten => 110,1,NoOp(Print the context)
same => n,Dial(PJSIP/110,10)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
exten => 111,1,NoOp(Print the context)
same => n,Dial(PJSIP/111, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
exten => 112,1,NoOp(Print the context)
same => n,Dial(PJSIP/112, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
Step 4: Open another tab in the terminal as shown in below image.

Step 5: Login to the Asterisk Console by using following command.
root@linuxhelp:~# asterisk -rvvvvvvvvvvvvvvvvvvvv
Asterisk 20.4.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.4.0 currently running on linuxhelp (pid = 1043)
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.000080 sec
-- Time to restore hints and swap in new dialplan: 0.000085 sec
-- Time to delete the old dialplan: 0.000032 sec
-- Total time merge_contexts_delete: 0.000197 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details).
Step 7: Check the connections by making call by using MicroSIP Software as shown in below image.

Step 8: Open and edit the extensions.conf file for use Goto application by using the below command.
root@linuxhelp:/etc/asterisk# vim extensions.conf
[internal]
exten => 110,1,NoOp(Print the context)
same => n,Goto(111,2)
same => n,Dial(PJSIP/110,10)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
exten => 111,1,NoOp(Print the context)
same => n,Dial(PJSIP/111, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
exten => 112,1,NoOp(Print the context)
same => n,Dial(PJSIP/112, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
Step 9: Goto the asterisk console and reload 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.000032 sec
-- Time to restore hints and swap in new dialplan: 0.000005 sec
-- Time to delete the old dialplan: 0.000004 sec
-- Total time merge_contexts_delete: 0.000041 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details).
Step 10: Again, Check the connections by making call by using MicroSIP Software as shown in below image.

Step 11: Again, Open and Edit the extensions.conf file for use GotoIf application by using the below command.
root@linuxhelp:/etc/asterisk# vim extensions.conf
[internal]
exten => 110,1,NoOp(Print the context)
same => n,SET(TEST=1)
same => n,GotoIf($[ ${TEST} = 1]?111,2:110,4)
same => n,Dial(PJSIP/110,10)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
exten => 111,1,NoOp(Print the context)
same => n,Dial(PJSIP/111, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
exten => 112,1,NoOp(Print the context)
same => n,Dial(PJSIP/112, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
Step 12: Goto the asterisk console and reload 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.000005 sec
-- Time to restore hints and swap in new dialplan: 0.000005 sec
-- Time to delete the old dialplan: 0.000004 sec
-- Total time merge_contexts_delete: 0.000014 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details
Step 13: Check the connections by making call by using MicroSIP Software as shown in below image.

Step 14: Open and edit the extensions.conf file for make some changes in the GotoIf conditions by using the below command.
root@linuxhelp:/etc/asterisk# vim extensions.conf
[internal]
exten => 110,1,NoOp(Print the context)
same => n,SET(TEST=2)
same => n,GotoIf($[ ${TEST} = 1]?111,2:110,4)
same => n,Dial(PJSIP/110,10)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
exten => 111,1,NoOp(Print the context)
same => n,Dial(PJSIP/111, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
exten => 112,1,NoOp(Print the context)
same => n,Dial(PJSIP/112, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()
Step 15: Goto the asterisk console and reload 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.000005 sec
-- Time to restore hints and swap in new dialplan: 0.000005 sec
-- Time to delete the old dialplan: 0.000004 sec
-- Total time merge_contexts_delete: 0.000014 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details).
Step 16: Again, Check the connections by making call by using MicroSIP Software as shown in below image.

Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to use Asterisk Goto and GotoIf application on Debian 12. Your feedback is much welcome.
Comments ( 0 )
No comments available