Asterisk Dialplan Globals

Dialplan Global Variables

Dialplan global variables and their initial values are defined in the extensions.conf file following the Dialplan General Settings. The global variables section begins with the header:


Following this header you may define global variables and their initial values.

Actually, Asterisk global variables are usually used not as variables but as constants. They are usually used to have a single place in your dialplan where you can specify values that you might want to change in the future if you change your PBX configuration.

The current value of a global variable can be changed in a dialplan using the SetGlobalVar command. The current value of a global variable can be referenced within the dialplan using the syntax:


Note that global variable names are not case sensitive. ${MYGLOBAL} and ${myGLObal} are equivalent.


Here is an example which defines some global variables used in the dialplan of a home PBX.


; Which extensions shall we ring when an incoming call comes in?
INCOMING => Zap/3&Zap/4

; How long shall we ring those extensions before going to voicemail instead?

; What sound file will we play as a voicemail announcement?
VMANNOUNCE => mysounds/my-vm-announce

; Define the channels our extensions are connected on
KITCHEN => Zap/3
STUDY => Zap/4
HALL => Zap/5

; When we want to make an outgoing call, what line(s) can we use?
OUTGOING => Zap/1&Zap/2

Making these definitions does not, by itself, do anything. Asterisk does not intrinsically know what to do with a variable named "INCOMING", for example. It's up to you to define the variables you want and to make use of them the way you want in your dialplan.

In this example, the global variables have all been written with names in UPPERCASE. Global variable names are not case sensitive. Using uppercase for global variable names is just a convention to easily distinguish global variables from channel variables, which are often written in MixedCase.

Including Globals defined in other files

; A plus is needed (tested in 1.4.28) to add on to globals defined in extensions.conf
EXTRA_VAR => Zap/6

Checking defined globals

asterisk -rx 'core show globals'

For more information about using both global variables and channel variables in extensions.conf, see

See Also

Asterisk | Configuration | The Dialplan - extensions.conf
Created by: JazEzork, Last modification: Mon 10 of Oct, 2011 (12:26 UTC) by nilek
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+