How to use Asterisk Dialplan Context Priority Label on Debian 12

To Use Asterisk Dialplan Context Priority Label On Debian 12

Introduction

Asterisk's common practice is to assign text labels to priorities. This is to ensure that you can refer to a priority by something other than its number, which probably isn’t known, given that dialplans now generally use unnumbered priorities. To assign a text label to a priority, simply add the label inside parentheses after the priority.

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: Check the asterisk version by using the below command.

root@linuxhelp:~#asterisk -V
Asterisk 20.4.0

Step 3: Go to the following location by using the below command.

root@linuxhelp:~#cd /etc/asterisk/

Step 4: Edit extension.conf file for making dialplan using priority label by using the below command.

root@linuxhelp:/etc/asterisk#vim extensions.conf
[internal]
exten => 110,1,NoOp(Print the context)
same => n,Goto(111,test)
same => n,Dial(PJSIP/110, 20)
same => n,Playback(sorry_didnt_get)
same => n,Hangup()

exten => 111,1,NoOp(Print the context)
same => n,Dial(PJSIP/111, 20)
same => n(test),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 5: Login to the asterisk console by using the below command.

ot@linuxhelp:/etc/asterisk#asterisk -rvvvvvvvvvvvvvvvvvvvvv
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 = 946)
linuxhelp*CLI>

Step 6: Reload the dialplan by using following command.

nuxhelp*CLI> dialplan reload
Dialplan reloaded.
    -- Time to scan old dialplan and merge leftovers back into the new: 0.000007 sec
    -- Time to restore hints and swap in new dialplan: 0.000007 sec
    -- Time to delete the old dialplan: 0.000006 sec
    -- Total time merge_contexts_delete: 0.000020 sec
    -- pbx_config successfully loaded 1 contexts (enable debug for details).

Step 7: Make the call to check the priority label by using microsip application.

-- Executing [110@internal:1] NoOp("PJSIP/112-00000006", "Print the context") in new stack
-- Executing [110@internal:2] Goto("PJSIP/112-00000006", "111,test") in new stack
-- Goto (internal,111,3)
-- Executing [111@internal:3] Playback("PJSIP/112-00000006", "sorry_didnt_get") in new stack
   > 0x7effb0013680 -- Strict RTP learning after remote address set to: 192.168.6.102:4000
-- <PJSIP/112-00000006> Playing 'sorry_didnt_get.ulaw' (language 'en')
   > 0x7effb0013680 -- Strict RTP switching to RTP target address 192.168.6.102:4000 as source
-- Executing [111@internal:4] Hangup("PJSIP/112-00000006", "") in new stack

== Spawn extension (internal, 111, 4) exited non-zero on 'PJSIP/112-00000006'

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to use Asterisk Dialplan Context Priority Label on Debian 12. Your feedback is much welcome.

FAQ
Q
Can I use non-alphanumeric characters in priority labels?
A
No, only numbers (0-9) and lowercase letters (a-z) are valid label characters. Using other characters will result in a syntax error.
Q
Are there any best practices for using dialplan priority labels?
A
It is recommended to use meaningful and descriptive labels to improve clarity and maintainability of the dialplan. Additionally, ensure that the label names do not conflict with any reserved keywords or commands used by Asterisk.
Q
How can priority labels be helpful?
A
Priority labels can help you structure and organize your dialplan configuration. They allow for easier navigation within the dialplan and can be used to control the call flow based on specific conditions or requirements.
Q
Can I use multiple priority labels in the same dialplan?
A
Yes, you can use multiple priority labels in the same dialplan. Each label should have a unique name to avoid any conflicts.
Q
What are Asterisk dialplan priority labels?
A
Asterisk dialplan priority labels are markers used to identify specific sections or steps in the dialplan configuration. They allow you to organize and control the call flow within your Asterisk system.