set variable

Usage: SET VARIABLE <variablename> <value>

These variables live in the channel Asterisk creates when you pickup a phone and as such they are both local and temporary. Variables created in one channel can not be accessed by another channel. When you hang up the phone, the channel is deleted and any variables in that channel are deleted as well.

Just like get variable, this works for writing to functions too.

200 result=1

NOTE: currently (*version<= 1.2.11) the value cannot contain spaces. Putting quotes or double quotes around the value won't work. Workaround is to change spaces to e.g. underscores. In unix sh this would be something like : echo "part1 part2" | tr ' ' '_'

Using Asterisk Version 1.12.1 you should use the escape characters to set the variable correct. Something like: "SET VARIABLE TEST \"hello again\" \n");

Passing variables as a value of another variable

Variables such as channel variables set as a value for another variable should be replaced by the actual value for it will be read as a string.
This example won't work if issued to Dial command

The ${EXTEN} variable should be replaced by the actual dialed number. eg 12345678

in extensions.conf
  exten => s,1,Dial(${MY_DIALSTRING})

Go back to Asterisk AGI
Created by: pinhole, Last modification: Thu 11 of Dec, 2008 (17:40 UTC) by miken32
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+