How to set a global variable to use into all IVRs within a system

In the folder  /etc/asterisk/ and edit the file extensions_xcally_custom.conf


add the following section and define the global variables, for example: 

 

[globals](+)
GLOB_VAR = TEST
GLOB_VAR1 = TEST1

 

save the file and reload Asterisk.
[[email protected] ~]# asterisk -r

localhost*CLI> reload
Now you should be able to see the global variables value, for example
NoOP is set with:
GLOBAL VARIABLE = {GLOB_VAR}
and 
GLOBAL VARIABLE 1 = {GLOB_VAR1}
In the Asterisk CLI we can see the value of both globals variables:
<SIP/my.xcally-00000000>AGI Rx << GET VARIABLE GLOB_VAR
<SIP/my.xcally-00000000>AGI Tx >> 200 result=1 (TEST)
<SIP/my.xcally-00000000>AGI Rx << VERBOSE "GLOBAL VARIABLE = TEST" 1
agi://127.0.0.1/square,project=34: GLOBAL VARIABLE = TEST
<SIP/my.xcally-00000000>AGI Tx >> 200 result=1
<SIP/my.xcally-00000000>AGI Rx << GET VARIABLE GLOB_VAR1
<SIP/my.xcally-00000000>AGI Tx >> 200 result=1 (TEST1)
<SIP/my.xcally-00000000>AGI Rx << VERBOSE "GLOBAL VARIABLE 1 = TEST1" 1
agi://127.0.0.1/square,project=34: GLOBAL VARIABLE 1 = TEST1
<SIP/my.xcally-00000000>AGI Tx >> 200 result=1

 

To set a new value for the global variable use the CUSTOM APP block as below

 

 

Related issues