System information

changes to your dialplan, as you don’t have to keep renumbering all your steps. For
example, your dialplan might look something like this:
exten => 123,1,Answer()
exten => 123,n,do something
exten => 123,n,do something else
exten => 123,n,do one last thing
exten => 123,n,Hangup()
Internally, Asterisk will calculate the next priority number every time it encounters an
n.
Bear in mind that you must always specify priority number 1. If you accidentally
put an n instead of 1 for the first priority (a common mistake even among experienced
dialplan coders), you’ll find after reloading the dialplan that the extension will not exist.
The 'same =>' operator
In the never-ending effort to simplify coding effort, a new construct was created to make
extension building and management even easier. As long as the extension remains the
same, rather than having to type the full extension on each line, you can simply type
same => , followed by the priority and application:
exten => 123,1,Answer()
same => n,do something
same => n,do something else
same => n,do one last thing
same => n,Hangup()
The indentation is not required, but it may make for easier reading. This style of dialplan
will also make it easier to copy code from one extension to another. We prefer this style
ourselves, and highly recommend it.
Priority labels
Priority labels allow you to assign a name to a priority within an extension. 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).
The reason it is important to be able to address a particular priority in an extension is
that you will often want to send calls from other parts of the dialplan to a particular
priority in a particular extension. We’ll talk about that more later. To assign a text label
to a priority, simply add the label inside parentheses after the priority, like this:
exten => 123,n(label),application()
Later, we’ll cover how to jump between different priorities based on dialplan logic.
You’ll see a lot more of priority labels, and you’ll use them often in your dialplans.
‡ Asterisk permits simple arithmetic within the priority, such as n+200, and the priority s (for same), but their
usage is somewhat deprecated due to the existence of priority labels. Please note that extension s and priority
s are two distinct concepts.
112 | Chapter 6:Dialplan Basics