Question

I have an example asterisk dial plan below.It just the main (no extension or start) and it has 3 priorities.In the first priority of our extension, we’ll answer the call. In the second, we’ll play a sound file named hello-world.gsm, and in the third we’ll hang up the call

One example on the web seem to suggest the below format

[incoming]
exten => s,1,Answer()
exten => s,n,Playback(hello-world)
exten => s,n,Hangup()

instead of

[incoming]
exten => s,1,Answer()
exten => s,2,Playback(hello-world)
exten => s,3,Hangup()

why is that? what exactly is a priority ? and what does 'n' signify

Was it helpful?

Solution

Asterisk executes each priority in numerical order, and like in BASIC, you can jump to those Priorities with Goto.

Since Asterisk 1.2 you have the ability to use the n priority.

The n priority adds 1 to the previous Prioritiy.

That makes you more flexible, you could add a Line, without the need to care about the Priorities.

Another Benefit of the n priority is that you can use the n Priority with optional Labels and jump to that Label, instead of messing arround with the priorities Counter.

[incoming]
exten => s,1,Answer()
exten => s,n(Start),Background(hello-world)
exten => s,n,Goto(Start)
exten => s,n,Hangup()

See GotoIf for more examples.

OTHER TIPS

The best way to do this the following

exten => s,1,Answer() ;answer the call
same => n,playback(youfilename) ;understand that Asterisk will pick the best format to play
same => n,Hangup()

When using the same keyword you do not need to use the 's' in the dial plan.

You can also save a bit of typing using the "same" construct on Asterisk 1.6+:

[incoming]
exten => s,1,Answer()
 same => n(Start),Background(hello-world)
 same => n,Goto(Start)
 same => n,Hangup()

... if you are doing large dialplans where you are doing a bit of cut-paste-tweak between different sections, such as IVRs, using "same" saves you from making an error with the extension number.

Further reading: https://wiki.asterisk.org/wiki/display/AST/Contexts,+Extensions,+and+Priorities

n stands for Next Priority.

In place of writing number in priority we can use "n" to represent the next node.

We can also use label with "n" e.g. exten => s,n(dosomething) if we are using goto or gotoif conditions in our dialplan then this labels help us to navigate to different "n" priority.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top