README.variables 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. ----------------------------
  2. Asterisk dial plan variables
  3. ----------------------------
  4. There are two levels of parameter evaluation done in the Asterisk
  5. dial plan in extensions.conf.
  6. * The first, and most frequently used, is the substitution of variable
  7. references with their values.
  8. * Then there are the evaluations of expressions done in $[ .. ].
  9. This will be discussed below.
  10. Asterisk has user-defined variables and standard variables set
  11. by various modules in Asterisk. These standard variables are
  12. listed at the end of this document.
  13. ___________________________
  14. PARAMETER QUOTING:
  15. ---------------------------
  16. exten => s,5,BackGround,blabla
  17. The parameter (blabla) can be quoted ("blabla"). In this case, a
  18. comma does not terminate the field. However, the double quotes
  19. will be passed down to the Background command, in this example.
  20. Also, characters special to variable substitution, expression evaluation, etc
  21. (see below), can be quoted. For example, to literally use a $ on the
  22. string "$1231", quote it with a preceding \. Special characters that must
  23. be quoted to be used, are [ ] $ " \. (to write \ itself, use \\).
  24. These Double quotes and escapes are evaluated at the level of the
  25. asterisk config file parser.
  26. Double quotes can also be used inside expressions, as discussed below.
  27. ___________________________
  28. VARIABLES:
  29. ---------------------------
  30. Parameter strings can include variables. Variable names are arbitrary strings.
  31. They are stored in the respective channel structure.
  32. To set a variable to a particular value, do :
  33. exten => 1,2,Set(varname=value)
  34. You can substitute the value of a variable everywhere using ${variablename}.
  35. For example, to stringwise append $lala to $blabla and store result in $koko,
  36. do:
  37. exten => 1,2,Set(koko=${blabla}${lala})
  38. There are two reference modes - reference by value and reference by name.
  39. To refer to a variable with its name (as an argument to a function that
  40. requires a variable), just write the name. To refer to the variable's value,
  41. enclose it inside ${}. For example, Set takes as the first argument
  42. (before the =) a variable name, so:
  43. exten => 1,2,Set(koko=lala)
  44. exten => 1,3,Set(${koko}=blabla)
  45. stores to the variable "koko" the value "lala" and to variable "lala" the
  46. value "blabla".
  47. In fact, everything contained ${here} is just replaced with the value of
  48. the variable "here".
  49. ____________________
  50. VARIABLE INHERITANCE
  51. --------------------
  52. Variable names which are prefixed by "_" will be inherited to channels
  53. that are created in the process of servicing the original channel in
  54. which the variable was set. When the inheritance takes place, the
  55. prefix will be removed in the channel inheriting the variable. If the
  56. name is prefixed by "__" in the channel, then the variable is
  57. inherited and the "__" will remain intact in the new channel.
  58. In the dialplan, all references to these variables refer to the same
  59. variable, regardless of having a prefix or not. Note that setting any
  60. version of the variable removes any other version of the variable,
  61. regardless of prefix.
  62. Example:
  63. Set(__FOO=bar) ; Sets an inherited version of "FOO" variable
  64. Set(FOO=bar) ; Removes the inherited version and sets a local
  65. ; variable.
  66. However,
  67. NoOp(${__FOO}) is identical to NoOp(${FOO})
  68. ___________________________________
  69. SELECTING CHARACTERS FROM VARIABLES
  70. -----------------------------------
  71. The format for selecting characters from a variable can be expressed as:
  72. ${variable_name[:offset[:length]]}
  73. If you want to select the first N characters from the string assigned
  74. to a variable, simply append a colon and the number of characters to
  75. skip from the beginning of the string to the variable name.
  76. ;Remove the first character of extension, save in "number" variable
  77. exten => _9X.,1,Set(number=${EXTEN:1})
  78. Assuming we've dialed 918005551234, the value saved to the 'number' variable
  79. would be 18005551234. This is useful in situations when we require users to
  80. dial a number to access an outside line, but do not wish to pass the first
  81. digit.
  82. If you use a negative offset number, Asterisk starts counting from the end
  83. of the string and then selects everything after the new position. The following
  84. example will save the numbers 1234 to the 'number' variable, still assuming
  85. we've dialed 918005551234.
  86. ;Remove everything before the last four digits of the dialed string
  87. exten => _9X.,1,Set(number=${EXTEN:-4})
  88. We can also limit the number of characters from our offset position that we
  89. wish to use. This is done by appending a second colon and length value to the
  90. variable name. The following example will save the numbers 555 to the 'number'
  91. variable.
  92. ;Only save the middle numbers 555 from the string 918005551234
  93. exten => _9X.,1,Set(number=${EXTEN:5:3})
  94. The length value can also be used in conjunction with a negative offset. This
  95. may be useful if the length of the string is unknown, but the trailing digits
  96. are. The following example will save the numbers 555 to the 'number' variable,
  97. even if the string starts with more characters than expected (unlike the
  98. previous example).
  99. ;Save the numbers 555 to the 'number' variable
  100. exten => _9X.,1,Set(number=${EXTEN:-7:3})
  101. If a negative length value is entered, it is ignored and Asterisk will match
  102. to the end of the string.
  103. ___________________________
  104. EXPRESSIONS:
  105. ---------------------------
  106. Everything contained inside a bracket pair prefixed by a $ (like $[this]) is
  107. considered as an expression and it is evaluated. Evaluation works similar to
  108. (but is done on a later stage than) variable substitution: the expression
  109. (including the square brackets) is replaced by the result of the expression
  110. evaluation.
  111. For example, after the sequence:
  112. exten => 1,1,Set(lala=$[1 + 2])
  113. exten => 1,2,Set(koko=$[2 * ${lala}])
  114. the value of variable koko is "6".
  115. and, further:
  116. exten => 1,1,Set,(lala=$[ 1 + 2 ]);
  117. will parse as intended. Extra spaces are ignored.
  118. ______________________________
  119. SPACES INSIDE VARIABLE VALUES
  120. ------------------------------
  121. If the variable being evaluated contains spaces, there can be problems.
  122. For these cases, double quotes around text that may contain spaces
  123. will force the surrounded text to be evaluated as a single token.
  124. The double quotes will be counted as part of that lexical token.
  125. As an example:
  126. exten => s,6,GotoIf($[ "${CALLERIDNAME}" : "Privacy Manager" ]?callerid-liar|s|1:s|7)
  127. The variable CALLERIDNAME could evaluate to "DELOREAN MOTORS" (with a space)
  128. but the above will evaluate to:
  129. "DELOREAN MOTORS" : "Privacy Manager"
  130. and will evaluate to 0.
  131. The above without double quotes would have evaluated to:
  132. DELOREAN MOTORS : Privacy Manager
  133. and will result in syntax errors, because token DELOREAN is immediately
  134. followed by token MOTORS and the expression parser will not know how to
  135. evaluate this expression, because it does not match its grammar.
  136. _____________________
  137. OPERATORS
  138. ---------------------
  139. Operators are listed below in order of increasing precedence. Operators
  140. with equal precedence are grouped within { } symbols.
  141. expr1 | expr2
  142. Return the evaluation of expr1 if it is neither an empty string
  143. nor zero; otherwise, returns the evaluation of expr2.
  144. expr1 & expr2
  145. Return the evaluation of expr1 if neither expression evaluates to
  146. an empty string or zero; otherwise, returns zero.
  147. expr1 {=, >, >=, <, <=, !=} expr2
  148. Return the results of integer comparison if both arguments are
  149. integers; otherwise, returns the results of string comparison
  150. using the locale-specific collation sequence. The result of each
  151. comparison is 1 if the specified relation is true, or 0 if the
  152. relation is false.
  153. expr1 {+, -} expr2
  154. Return the results of addition or subtraction of integer-valued
  155. arguments.
  156. expr1 {*, /, %} expr2
  157. Return the results of multiplication, integer division, or
  158. remainder of integer-valued arguments.
  159. - expr1
  160. Return the result of subtracting expr1 from 0.
  161. This, the unary minus operator, is right associative, and
  162. has the same precedence as the ! operator.
  163. expr1 : expr2
  164. The `:' operator matches expr1 against expr2, which must be a
  165. regular expression. The regular expression is anchored to the
  166. beginning of the string with an implicit `^'.
  167. If the match succeeds and the pattern contains at least one regu-
  168. lar expression subexpression `\(...\)', the string correspond-
  169. ing to `\1' is returned; otherwise the matching operator
  170. returns the number of characters matched. If the match fails and
  171. the pattern contains a regular expression subexpression the null
  172. string is returned; otherwise 0.
  173. Normally, the double quotes wrapping a string are left as part
  174. of the string. This is disastrous to the : operator. Therefore,
  175. before the regex match is made, beginning and ending double quote
  176. characters are stripped from both the pattern and the string.
  177. expr1 ? expr2 :: expr3
  178. Traditional Conditional operator. If expr1 is a number
  179. that evaluates to 0 (false), expr3 is result of the this
  180. expression evaluation. Otherwise, expr2 is the result.
  181. If expr1 is a string, and evaluates to an empty string,
  182. or the two characters (""), then expr3 is the
  183. result. Otherwise, expr2 is the result. In Asterisk, all
  184. 3 exprs will be "evaluated"; if expr1 is "true", expr2
  185. will be the result of the "evaluation" of this
  186. expression. expr3 will be the result otherwise. This
  187. operator has the lowest precedence.
  188. Parentheses are used for grouping in the usual manner.
  189. Operator precedence is applied as one would expect in any of the C
  190. or C derived languages.
  191. Examples
  192. "One Thousand Five Hundred" : "T[^ ]+"
  193. returns: 0
  194. "8015551212" : "(...)"
  195. returns: 801
  196. "3075551212":"...(...)"
  197. returns: 555
  198. !( "One Thousand Five Hundred" : "T[^ ]+" )
  199. returns: 1 (because the string doesn't start with a word starting
  200. with T, so the match evals to 0, and the ! operator
  201. inverts it to 1 ).
  202. 2 + 8 / 2
  203. returns 6. (because of operator precedence; the division is done first, then the addition).
  204. 2+8/2
  205. returns 6. Spaces aren't necessary.
  206. (2+8)/2
  207. returns 5, of course.
  208. Of course, all of the above examples use constants, but would work the
  209. same if any of the numeric or string constants were replaced with a
  210. variable reference ${CALLERIDNUM}, for instance.
  211. __________________________
  212. NUMBERS VS STRINGS
  213. --------------------------
  214. Tokens consisting only of numbers are converted to 64-bit numbers for
  215. most of the operators. This means that overflows can occur when the
  216. numbers get above 18 digits. Warnings will appear in the logs in this
  217. case.
  218. ___________________________
  219. CONDITIONALS
  220. ---------------------------
  221. There is one conditional application - the conditional goto :
  222. exten => 1,2,gotoif(condition?label1:label2)
  223. If condition is true go to label1, else go to label2. Labels are interpreted
  224. exactly as in the normal goto command.
  225. "condition" is just a string. If the string is empty or "0", the condition
  226. is considered to be false, if it's anything else, the condition is true.
  227. This is designed to be used together with the expression syntax described
  228. above, eg :
  229. exten => 1,2,gotoif($[${CALLERID} = 123456]?2|1:3|1)
  230. Example of use :
  231. exten => s,2,Set(vara=1)
  232. exten => s,3,Set(varb=$[${vara} + 2])
  233. exten => s,4,Set(varc=$[${varb} * 2])
  234. exten => s,5,GotoIf($[${varc} = 6]?99|1:s|6)
  235. ___________________________
  236. PARSE ERRORS
  237. ---------------------------
  238. Syntax errors are now output with 3 lines.
  239. If the extensions.conf file contains a line like:
  240. exten => s,6,GotoIf($[ "${CALLERIDNUM}" = "3071234567" & & "${CALLERIDNAME}" : "Privacy Manager" ]?callerid-liar|s|1:s|7)
  241. You may see an error in /var/log/asterisk/messages like this:
  242. Jul 15 21:27:49 WARNING[1251240752]: ast_yyerror(): syntax error: parse error, unexpected TOK_AND, expecting TOK_MINUS or TOK_LP or TOKEN; Input:
  243. "3072312154" = "3071234567" & & "Steves Extension" : "Privacy Manager"
  244. ^
  245. The log line tells you that a syntax error was encountered. It now
  246. also tells you (in grand standard bison format) that it hit an "AND"
  247. (&) token unexpectedly, and that was hoping for for a MINUS (-), LP
  248. (left parenthesis), or a plain token (a string or number).
  249. The next line shows the evaluated expression, and the line after
  250. that, the position of the parser in the expression when it became confused,
  251. marked with the "^" character.
  252. ___________________________
  253. NULL STRINGS
  254. ---------------------------
  255. Testing to see if a string is null can be done in one of two different ways:
  256. exten => _XX.,1,GotoIf($["${calledid}" != ""]?3)
  257. exten => _XX.,1,GotoIf($[foo${calledid} != foo]?3)
  258. The second example above is the way suggested by the WIKI. It will
  259. work as long as there are no spaces in the evaluated value.
  260. The first way should work in all cases, and indeed, might now
  261. be the safest way to handle this situation.
  262. ___________________________
  263. WARNING
  264. ---------------------------
  265. If you need to do complicated things with strings, asterisk expressions
  266. is most likely NOT the best way to go about it. AGI scripts are an
  267. excellent option to this need, and make available the full power of
  268. whatever language you desire, be it Perl, C, C++, Cobol, RPG, Java,
  269. Snobol, PL/I, Scheme, Common Lisp, Shell scripts, Tcl, Forth, Modula,
  270. Pascal, APL, assembler, etc.
  271. ----------------------------
  272. INCOMPATIBILITIES
  273. ----------------------------
  274. The asterisk expression parser has undergone some evolution. It is hoped
  275. that the changes will be viewed as positive.
  276. The "original" expression parser had a simple, hand-written scanner,
  277. and a simple bison grammar. This was upgraded to a more involved bison
  278. grammar, and a hand-written scanner upgraded to allow extra spaces,
  279. and to generate better error diagnostics. This upgrade required bison
  280. 1.85, and part of the user community felt the pain of having to
  281. upgrade their bison version.
  282. The next upgrade included new bison and flex input files, and the makefile
  283. was upgraded to detect current version of both flex and bison, conditionally
  284. compiling and linking the new files if the versions of flex and bison would
  285. allow it.
  286. If you have not touched your extensions.conf files in a year or so, the
  287. above upgrades may cause you some heartburn in certain circumstances, as
  288. several changes have been made, and these will affect asterisk's behavior on
  289. legacy extension.conf constructs. The changes have been engineered
  290. to minimize these conflicts, but there are bound to be problems.
  291. The following list gives some (and most likely, not all) of areas
  292. of possible concern with "legacy" extension.conf files:
  293. 1. Tokens separated by space(s).
  294. Previously, tokens were separated by spaces. Thus, ' 1 + 1 ' would evaluate
  295. to the value '2', but '1+1' would evaluate to the string '1+1'. If this
  296. behavior was depended on, then the expression evaluation will break. '1+1'
  297. will now evaluate to '2', and something is not going to work right.
  298. To keep such strings from being evaluated, simply wrap them in double
  299. quotes: ' "1+1" '
  300. 2. The colon operator. In versions previous to double quoting, the
  301. colon operator takes the right hand string, and using it as a
  302. regex pattern, looks for it in the left hand string. It is given
  303. an implicit ^ operator at the beginning, meaning the pattern
  304. will match only at the beginning of the left hand string.
  305. If the pattern or the matching string had double quotes around
  306. them, these could get in the way of the pattern match. Now,
  307. the wrapping double quotes are stripped from both the pattern
  308. and the left hand string before applying the pattern. This
  309. was done because it recognized that the new way of
  310. scanning the expression doesn't use spaces to separate tokens,
  311. and the average regex expression is full of operators that
  312. the scanner will recognize as expression operators. Thus, unless
  313. the pattern is wrapped in double quotes, there will be trouble.
  314. For instance, ${VAR1} : (Who|What*)+
  315. may have have worked before, but unless you wrap the pattern
  316. in double quotes now, look out for trouble! This is better:
  317. "${VAR1}" : "(Who|What*)+"
  318. and should work as previous.
  319. 3. Variables and Double Quotes
  320. Before these changes, if a variable's value contained one or more double
  321. quotes, it was no reason for concern. It is now!
  322. 4. LE, GE, NE operators removed. The code supported these operators,
  323. but they were not documented. The symbolic operators, <=, >=, and !=
  324. should be used instead.
  325. 5. Added the unary '-' operator. So you can 3+ -4 and get -1.
  326. 6. Added the unary '!' operator, which is a logical complement.
  327. Basically, if the string or number is null, empty, or '0',
  328. a '1' is returned. Otherwise a '0' is returned.
  329. 7. Added the '=~' operator, just in case someone is just looking for
  330. match anywhere in the string. The only diff with the ':' is that
  331. match doesn't have to be anchored to the beginning of the string.
  332. 8. Added the conditional operator 'expr1 ? true_expr :: false_expr'
  333. First, all 3 exprs are evaluated, and if expr1 is false, the 'false_expr'
  334. is returned as the result. See above for details.
  335. 9. Unary operators '-' and '!' were made right associative.
  336. --------------------------------------------------------
  337. DEBUGGING HINTS FOR $[ ] EXPRESSIONS
  338. --------------------------------------------------------
  339. There are two utilities you can build to help debug the $[ ] in
  340. your extensions.conf file.
  341. The first, and most simplistic, is to issue the command:
  342. make testexpr2
  343. in the top level asterisk source directory. This will build a small
  344. executable, that is able to take the first command line argument, and
  345. run it thru the expression parser. No variable substitutions will be
  346. performed. It might be safest to wrap the expression in single
  347. quotes...
  348. testexpr2 '2*2+2/2'
  349. is an example.
  350. And, in the utils directory, you can say:
  351. make check_expr
  352. and a small program will be built, that will check the file mentioned
  353. in the first command line argument, for any expressions that might be
  354. have problems when you move to flex-2.5.31. It was originally
  355. designed to help spot possible incompatibilities when moving from the
  356. pre-2.5.31 world to the upgraded version of the lexer.
  357. But one more capability has been added to check_expr, that might make
  358. it more generally useful. It now does a simple minded evaluation of
  359. all variables, and then passes the $[] exprs to the parser. If there
  360. are any parse errors, they will be reported in the log file. You can
  361. use check_expr to do a quick sanity check of the expressions in your
  362. extensions.conf file, to see if they pass a crude syntax check.
  363. The "simple-minded" variable substitution replaces ${varname} variable
  364. references with '555'. You can override the 555 for variable values,
  365. by entering in var=val arguments after the filename on the command
  366. line. So...
  367. check_expr /etc/asterisk/extensions.conf CALLERIDNUM=3075551212 DIALSTATUS=TORTURE EXTEN=121
  368. will substitute any ${CALLERIDNUM} variable references with
  369. 3075551212, any ${DIALSTATUS} variable references with 'TORTURE', and
  370. any ${EXTEN} references with '121'. If there is any fancy stuff
  371. going on in the reference, like ${EXTEN:2}, then the override will
  372. not work. Everything in the ${...} has to match. So, to substitute
  373. #{EXTEN:2} references, you'd best say:
  374. check_expr /etc/asterisk/extensions.conf CALLERIDNUM=3075551212 DIALSTATUS=TORTURE EXTEN:2=121
  375. on stdout, you will see something like:
  376. OK -- $[ "${DIALSTATUS}" = "TORTURE" | "${DIALSTATUS}" = "DONTCALL" ] at line 416
  377. In the expr2_log file that is generated, you will see:
  378. line 416, evaluation of $[ "TORTURE" = "TORTURE" | "TORTURE" = "DONTCALL" ] result: 1
  379. check_expr is a very simplistic algorithm, and it is far from being
  380. guaranteed to work in all cases, but it is hoped that it will be
  381. useful.
  382. ---------------------------------------------------------
  383. Asterisk standard channel variables
  384. ---------------------------------------------------------
  385. There are a number of variables that are defined or read
  386. by Asterisk. Here is a list of them. More information is
  387. available in each application's help text. All these variables
  388. are in UPPER CASE only.
  389. Variables marked with a * are builtin functions and can't be set,
  390. only read in the dialplan. Writes to such variables are silently
  391. ignored.
  392. ${ACCOUNTCODE} * Account code (if specified) (Deprecated; use ${CDR(accountcode)})
  393. ${BLINDTRANSFER} The name of the channel on the other side of a blind transfer
  394. ${BRIDGEPEER} Bridged peer
  395. ${CALLERANI} * Caller ANI (PRI channels) (Deprecated; use ${CALLERID(ani)})
  396. ${CALLERID} * Caller ID (Deprecated; use ${CALLERID(all)})
  397. ${CALLERIDNAME} * Caller ID Name only (Deprecated; use ${CALLERID(name)})
  398. ${CALLERIDNUM} * Caller ID Number only (Deprecated; use ${CALLERID(num)})
  399. ${CALLINGANI2} * Caller ANI2 (PRI channels)
  400. ${CALLINGPRES} * Caller ID presentation for incoming calls (PRI channels)
  401. ${CALLINGTNS} * Transit Network Selector (PRI channels)
  402. ${CALLINGTON} * Caller Type of Number (PRI channels)
  403. ${CHANNEL} * Current channel name
  404. ${CONTEXT} * Current context
  405. ${DATETIME} * Current date time in the format: DDMMYYYY-HH:MM:SS (Deprecated; use ${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)})
  406. ${DB_RESULT} Result value of DB_EXISTS() dial plan function
  407. ${DNID} * Dialed Number Identifier (Deprecated; use ${CALLERID(dnid)})
  408. ${EPOCH} * Current unix style epoch
  409. ${EXTEN} * Current extension
  410. ${ENV(VAR)} Environmental variable VAR
  411. ${GOTO_ON_BLINDXFR} Transfer to the specified context/extension/priority
  412. after a blind transfer (use ^ characters in place of
  413. | to separate context/extension/priority when setting
  414. this variable from the dialplan)
  415. ${HANGUPCAUSE} * Asterisk cause of hangup (inbound/outbound)
  416. ${HINT} * Channel hints for this extension
  417. ${HINTNAME} * Suggested Caller*ID name for this extension
  418. ${INVALID_EXTEN} The invalid called extension (used in the "i" extension)
  419. ${LANGUAGE} * Current language (Deprecated; use ${LANGUAGE()})
  420. ${LEN(VAR)} * String length of VAR (integer)
  421. ${PRIORITY} * Current priority in the dialplan
  422. ${PRIREDIRECTREASON} Reason for redirect on PRI, if a call was directed
  423. ${RDNIS} * Redirected Dial Number ID Service (Deprecated; use ${CALLERID(rdnis)})
  424. ${TIMESTAMP} * Current date time in the format: YYYYMMDD-HHMMSS (Deprecated; use ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})
  425. ${TRANSFER_CONTEXT} Context for transferred calls
  426. ${UNIQUEID} * Current call unique identifier
  427. Application return values
  428. -------------------------
  429. In Asterisk 1.2, many applications return the result in a variable
  430. instead of, as in Asterisk 1.0, changing the dial plan priority (+101).
  431. For the various status values, see each application's help text.
  432. ${AQMSTATUS} * addqueuemember()
  433. ${AVAILSTATUS} * chanisavail()
  434. ${CHECKGROUPSTATUS} * checkgroup()
  435. ${CHECKMD5STATUS} * checkmd5()
  436. ${CPLAYBACKSTATUS} * controlplayback()
  437. ${DIALSTATUS} * dial()
  438. ${DBGETSTATUS} * dbget()
  439. ${ENUMSTATUS} * enumlookup()
  440. ${HASVMSTATUS} * hasnewvoicemail()
  441. ${LOOKUPBLSTATUS} * lookupblacklist()
  442. ${OSPLOOKUPSTATUS} * osplookup()
  443. ${OSPNEXTSTATUS} * ospnext()
  444. ${OSPFINISHSTATUS} * ospfinish()
  445. ${PLAYBACKSTATUS} * playback()
  446. ${PQMSTATUS} * pausequeuemember()
  447. ${PRIVACYMGRSTATUS} * privacymanager()
  448. ${QUEUESTATUS} * queue()
  449. ${RQMSTATUS} * removequeuemember()
  450. ${SENDIMAGESTATUS} * sendimage()
  451. ${SENDTEXTSTATUS} * sendtext()
  452. ${SENDURLSTATUS} * sendurl()
  453. ${SIPGETSTATUS} * sipgetheader()
  454. ${SYSTEMSTATUS} * system()
  455. ${TRANSFERSTATUS} * transfer()
  456. ${TXTCIDNAMESTATUS} * txtcidname()
  457. ${UPQMSTATUS} * unpausequeuemember()
  458. ${VMSTATUS} * voicmail()
  459. ${VMBOXEXISTSSTATUS} * vmboxexists()
  460. ${WAITSTATUS} * waitforsilence()
  461. Various application variables
  462. -----------------------------
  463. ${CURL} * Resulting page content for curl()
  464. ${ENUM} * Result of application EnumLookup
  465. ${EXITCONTEXT} Context to exit to in IVR menu (app background())
  466. or in the RetryDial() application
  467. ${MONITOR} * Set to "TRUE" if the channel is/has been monitored (app monitor())
  468. ${MONITOR_EXEC} Application to execute after monitoring a call
  469. ${MONITOR_EXEC_ARGS} Arguments to application
  470. ${MONITOR_FILENAME} File for monitoring (recording) calls in queue
  471. ${QUEUE_PRIO} Queue priority
  472. ${QUEUESTATUS} Status of the call, one of:
  473. (TIMEOUT | FULL | JOINEMPTY | LEAVEEMPTY | JOINUNAVAIL | LEAVEUNAVAIL)
  474. ${RECORDED_FILE} * Recorded file in record()
  475. ${TALK_DETECTED} * Result from talkdetect()
  476. ${TOUCH_MONITOR} The filename base to use with Touch Monitor (auto record)
  477. ${TOUCH_MONITOR_FORMAT} The audio format to use with Touch Monitor (auto record)
  478. ${TXTCIDNAME} * Result of application TXTCIDName
  479. ${VPB_GETDTMF} chan_vpb
  480. The MeetMe Conference Bridge uses the following variables:
  481. ----------------------------------------------------------
  482. ${MEETME_RECORDINGFILE} Name of file for recording a conference with
  483. the "r" option
  484. ${MEETME_RECORDINGFORMAT} Format of file to be recorded
  485. ${MEETME_EXIT_CONTEXT} Context for exit out of meetme meeting
  486. ${MEETME_AGI_BACKGROUND} AGI script for Meetme (zap only)
  487. ${MEETMESECS} * Number of seconds a user participated in a MeetMe conference
  488. The VoiceMail() application uses the following variables:
  489. ---------------------------------------------------------
  490. ${VM_CATEGORY} Sets voicemail category
  491. ${VM_NAME} * Full name in voicemail
  492. ${VM_DUR} * Voicemail duration
  493. ${VM_MSGNUM} * Number of voicemail message in mailbox
  494. ${VM_CALLERID} * Voicemail Caller ID (Person leaving vm)
  495. ${VM_CIDNAME} * Voicemail Caller ID Name
  496. ${VM_CIDNUM} * Voicemail Caller ID Number
  497. ${VM_DATE} * Voicemail Date
  498. ${VM_MESSAGEFILE} * Path to message left by caller
  499. The VMAuthenticate() application uses the following variables:
  500. ---------------------------------------------------------
  501. ${AUTH_MAILBOX} * Authenticated mailbox
  502. ${AUTH_CONTEXT} * Authenticated mailbox context
  503. DUNDiLookup() uses the following variables
  504. ---------------------------------------------------------
  505. ${DUNDTECH} * The Technology of the result from a call to DUNDiLookup()
  506. ${DUNDDEST} * The Destination of the result from a call to DUNDiLookup()
  507. The Zaptel channel sets the following variables:
  508. ---------------------------------------------------------
  509. ${ANI2} * The ANI2 Code provided by the network on the incoming call.
  510. (ie, Code 29 identifies call as a Prison/Inmate Call)
  511. ${CALLTYPE} * Type of call (Speech, Digital, etc)
  512. ${CALLEDTON} * Type of number for incoming PRI extension
  513. i.e. 0=unknown, 1=international, 2=domestic, 3=net_specific,
  514. 4=subscriber, 6=abbreviated, 7=reserved
  515. ${CALLINGSUBADDR} * Called PRI Subaddress
  516. ${FAXEXTEN} * The extension called before being redirected to "fax"
  517. ${PRIREDIRECTREASON} * Reason for redirect, if a call was directed
  518. The SIP channel uses the following variables:
  519. ---------------------------------------------------------
  520. ${SIPCALLID} * SIP Call-ID: header verbatim (for logging or CDR matching)
  521. ${SIPDOMAIN} * SIP destination domain of an inbound call (if appropriate)
  522. ${SIPUSERAGENT} * SIP user agent
  523. ${SIPURI} * SIP uri
  524. ${SIP_CODEC} Set the SIP codec for a call
  525. ${SIP_URI_OPTIONS} * additional options to add to the URI for an outgoing call
  526. The Agent channel uses the following variables:
  527. ---------------------------------------------------------
  528. ${AGENTMAXLOGINTRIES} Set the maximum number of failed logins
  529. ${AGENTUPDATECDR} Whether to update the CDR record with Agent channel data
  530. ${AGENTGOODBYE} Sound file to use for "Good Bye" when agent logs out
  531. ${AGENTACKCALL} Whether the agent should acknowledge the incoming call
  532. ${AGENTAUTOLOGOFF} Auto logging off for an agent
  533. ${AGENTWRAPUPTIME} Setting the time for wrapup between incoming calls
  534. ${AGENTNUMBER} * Agent number (username) set at login
  535. ${AGENTSTATUS} * Status of login ( fail | on | off )
  536. ${AGENTEXTEN} * Extension for logged in agent
  537. The Dial() application uses the following variables:
  538. ---------------------------------------------------------
  539. ${DIALEDPEERNAME} * Dialed peer name
  540. ${DIALEDPEERNUMBER} * Dialed peer number
  541. ${DIALEDTIME} * Time for the call (seconds)
  542. ${ANSWEREDTIME} * Time from dial to answer (seconds)
  543. ${DIALSTATUS} * Status of the call, one of:
  544. (CHANUNAVAIL | CONGESTION | BUSY | NOANSWER
  545. | ANSWER | CANCEL | DONTCALL | TORTURE)
  546. ${DYNAMIC_FEATURES} * The list of features (from the [applicationmap] section of
  547. features.conf) to activate during the call, with feature
  548. names separated by '#' characters
  549. ${LIMIT_PLAYAUDIO_CALLER} Soundfile for call limits
  550. ${LIMIT_PLAYAUDIO_CALLEE} Soundfile for call limits
  551. ${LIMIT_WARNING_FILE} Soundfile for call limits
  552. ${LIMIT_TIMEOUT_FILE} Soundfile for call limits
  553. ${LIMIT_CONNECT_FILE} Soundfile for call limits
  554. ${OUTBOUND_GROUP} Default groups for peer channels (as in SetGroup)
  555. * See "show application dial" for more information
  556. The chanisavail() application sets the following variables:
  557. -----------------------------------------------------------
  558. ${AVAILCHAN} * the name of the available channel if one was found
  559. ${AVAILORIGCHAN} * the canonical channel name that was used to create the channel
  560. ${AVAILSTATUS} * Status of requested channel
  561. When using macros in the dialplan, these variables are available
  562. ---------------------------------------------------------
  563. ${MACRO_EXTEN} * The calling extensions
  564. ${MACRO_CONTEXT} * The calling context
  565. ${MACRO_PRIORITY} * The calling priority
  566. ${MACRO_OFFSET} Offset to add to priority at return from macro
  567. If you compile with OSP support in the SIP channel, these
  568. variables are used:
  569. ---------------------------------------------------------
  570. ${OSPHANDLE} Handle from the OSP Library
  571. ${OSPTECH} OSP Technology from Library
  572. ${OSPDEST} OSP Destination from Library
  573. ${OSPTOKEN} OSP Token to use for call from Library
  574. ${OSPRESULTS} Number of OSP results
  575. ____________________________________
  576. CDR Variables
  577. ------------------------------------
  578. If the channel has a cdr, that cdr record has it's own set of variables which
  579. can be accessed just like channel variables. The following builtin variables
  580. are available.
  581. ${CDR(clid)} Caller ID
  582. ${CDR(src)} Source
  583. ${CDR(dst)} Destination
  584. ${CDR(dcontext)} Destination context
  585. ${CDR(channel)} Channel name
  586. ${CDR(dstchannel)} Destination channel
  587. ${CDR(lastapp)} Last app executed
  588. ${CDR(lastdata)} Last app's arguments
  589. ${CDR(start)} Time the call started.
  590. ${CDR(answer)} Time the call was answered.
  591. ${CDR(end)} Time the call ended.
  592. ${CDR(duration)} Duration of the call.
  593. ${CDR(billsec)} Duration of the call once it was answered.
  594. ${CDR(disposition)} ANSWERED, NO ANSWER, BUSY
  595. ${CDR(amaflags)} DOCUMENTATION, BILL, IGNORE etc
  596. ${CDR(accountcode)} The channel's account code.
  597. ${CDR(uniqueid)} The channel's unique id.
  598. ${CDR(userfield)} The channels uses specified field.
  599. In addition, you can set your own extra variables with a traditional
  600. Set(CDR(var)=val) to anything you want.
  601. Certain functional variables may be accessed with ${foo(<args>)}. A list
  602. of these functional variables may be found by typing "show functions"
  603. at the Asterisk CLI.