Saturday, February 11, 2012

Asterisk Dialplan Variables

Three types of variables in Asterisk dialplan: global variables, channel variables, and environment variables.
1. Global variables should be declared in the [globals] context at the beginning of the extensions.conf file. They can also be defined programmatically, using the GLOBAL() dialplan function. For example,
[globals]
JOHN=Zap/1

[employees]
exten => 212, 1, Set(GLOBAL(GEORGE)=SIP/George)

2. Channel variables are variables that are associated only with a particular call. Channel variabbles are defined only for the duration of the current call and are available only to the channels participating in that call.
There are many predefined channel variables availabe for use within the dialplan, which are explained in the channelvariables.txt file in the doc subdirectory of Asterisk source. Channel variables are set via the Set() application:
exten => 125, 1, Set(MAGICNUMBER=42)

3. Environment variables are a way of accessing Unix environment variables from within Asterisk. These are referenced using the ENV() dialplan function. The syntax looks like ${ENV(var)}, where var is the Unix environment variable you wish to reference.

No comments:

Post a Comment