Asterisk - The Open Source Telephony Project GIT-master-2de1a68
Asterisk Dialplan Variables

Asterisk Dialplan variables are divided into three groups:

  • Predefined global variables, handled by the PBX core
  • Global variables, that exist for the duration of the pbx execution
  • Channel variables, that exist during a channel

Global variables are reachable in all channels, all of the time. Channel variables are only reachable within the channel.

For more information on the predefined variables, see Globally predefined channel variables

Global and Channel variables:

  • Names are Case insensitive
  • Names that start with a character, but are alphanumeric
  • Global variables are defined and reached with the GLOBAL() dialplan function and the set application, like

    exten => 1234,1,set(GLOBAL(myvariable)=tomteluva)

  • Channel variables are defined with the set() dialplan application

    exten => 1234,1,set(xmasattribute=tomtegröt)

  • Some channels also supports setting channel variables with the setvar= configuraiton option for a device or line.

Global Variables

Global variables can also be set in the [globals] section of extensions.conf. The setting clearglobalvars in extensions.conf [general] section affects whether or not the global variables defined in globals are reset at dialplan reload.

There are CLI commands to change and read global variables. This can be handy to reset counters at midnight from an external script.

Developer notes

Variable handling is managed within pbx.c You need to include pbx.h to reach these functions.

The variables is a linked list stored in the channel data structure with the list starting at varshead in struct ast_channel