Channel-specific predefined variables
The following is a list of channel-specific variables set by Asterisk itself, whose values you can use in dial plans. Unlike user-defined variables, variables defined by Asterisk are case-sensitive.
- ${ACCOUNTCODE}: Account code, if assigned - see Asterisk billing. (Deprecated starting from version 1.2.0 and removed in version 1.4.0. Use ${CDR(accountcode)} instead.)
- ${ANSWEREDTIME}: Time when the call was answered.
- ${BLINDTRANSFER}: Active SIP channel making the call. This will contain the name of the SIP channel that performs a blind transfer - see BLINDTRANSFER?
- ${CALLERID(all)} : Current value of the name and number from CallerID - See the section Setting Callerid?, dedicated to working with CallerID in Asterisk version 1.4
- ${CALLERID(name)} : Current value of the name from CallerID - The variable ${CALLERIDNAME} was used in Asterisk prior to version 1.2.0; it was deprecated starting from version 1.2.0 and removed in version 1.4.
- ${CALLERID(num)} : Current value of the number from CallerID - The variable ${CALLERIDNUM} was used in Asterisk prior to version 1.2.0; it was deprecated starting from version 1.2.0 and removed in version 1.4. (Note: The value of this variable does not necessarily have to be numeric, as its name might suggest, and a space character is a perfectly valid value. Commands that operate on the value of this variable (e.g., 'GotoIf') must take this into account.)
- ${CALLINGPRES}: Variable containing PRI Call ID Presentation, for incoming calls (See callingpres )
- ${CHANNEL}: Current channel name
- ${CONTEXT}: Current context name
- ${DATETIME}: Current time and date in the format: DDMMYYYY-HH:MM:SS This variable is deprecated in Asterisk version 1.2; instead, use the expression: ${STRFTIME(${EPOCH},,%d%mNaVH:NaVS)}
- ${DIALEDPEERNAME}: Name of the called peer. Currently not working, see DIALEDPEERNAME?
- ${DIALEDPEERNUMBER}: Number of the called peer. Currently not working, see DIALEDPEERNUMBER?
- ${DIALEDTIME}: Time when the number was dialed. (Works only if the called party answered the call?!)
- ${DIALSTATUS}: Call status. See DIALSTATUS
- ${DNID}: Dialed Number Identifier. For support of outgoing call restrictions, see DNID?
- ${EPOCH}: Current time in UNIX format (number of seconds elapsed since January 1, 1970)
- ${EXTEN}: Current extension
- ${HANGUPCAUSE}: Last return code returned upon connection termination for a Zap channel connected to a PRI interface
- ${INVALID_EXTEN}: Requested extension, in cases where it is redirected to processing by the i (invalid) extension
- ${LANGUAGE}: Current message language. See Asterisk multi-language?
- ${MEETMESECS}: Number of seconds the user participated in the MeetMe conference?.
- ${PRIORITY}: Current priority value.
- ${RDNIS}: Caller ID for the party performing redirection DNIS. For support of outgoing call restrictions, see RDNIS?
- ${SIPDOMAIN}: Destination domain for outgoing SIP calls (if present)
- ${SIP_CODEC}: Used to set the codec for a call via an SIP channel (presumably not working in version 1.0.1, OK in 1.0.3 & 1.0.4, uncertain about 1.0.2)
- ${SIPCALLID}: Value of the Call-ID: header field in SIP dialog messages.
- ${SIPUSERAGENT}: Value of the "user agent" header field in SIP dialog messages.
- ${TIMESTAMP}: Current date and time in the format: YYYYMMDD-HHMMSS This variable is deprecated in Asterisk version 1.2; instead, use the expression: ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}
- ${TRANSFERCAPABILITY}: Channel type.
- ${TXTCIDNAME}: Result of the TXTCIDName application (see below)
- ${UNIQUEID}: Current unique call identifier
- ${TOUCH_MONITOR}: Used for "one-touch recording" (see features.conf, and wW flags for the dial command). If set on both ends of the connection, this variable contains app_args (arguments) for the app_monitor application; otherwise, default arguments WAV||m are used.
- ${CONTEXT}: Name of the current context
- ${DATETIME}: Current date and time in the format: !YYYY-MM-DD_HH:MM:SS
- ${TIMESTAMP}: Current date and time in the format: YYYYMMDD-HHMMSS
- ${EPOCH}: Current UNIX epoch time (number of seconds since 1 Jan 1970)
- ${EXTEN}: Current telephone number (extension)
- ${INVALID_EXTEN}: Dialed telephone number when redirected to the i (invalid) extension
- ${LANGUAGE}: Current language value. See Asterisk's support for national languages
- ${PRIORITY}: Current priority
- ${CALLINGPRES}: PRI Call ID Presentation variable for incoming calls (See callingpres)
- ${CALLERID}: Calling identifier (name and number)
- ${CALLERIDNAME}: Calling identifier: name
- ${CALLERIDNUM}: Calling identifier: number
- ${CHANNEL}: Name of the current channel
- ${RDNIS}: The current redirecting DNIS, Caller ID that redirected the call. See RDNIS
- ${SIPDOMAIN}: SIP destination domain of an inbound call (if applicable)
- ${SIP_CODEC}: Used to set the SIP codec for a call
- ${SIPCALLID}: The SIP dialog Call-ID: header
- ${SIPUSERAGENT}: The SIP user agent header
- ${UNIQUEID}: Current SIP call unique ID
- ${HANGUPCAUSE}: The last hangup return code on a Zap channel connected to a PRI interface
- ${DNID}: Dialed Number Identifier
- ${ACCOUNTCODE}: Account code, if specified - see Asterisk billing
Variables used by various applications
Commands of some applications use the values of "channel" variables or return their results into them.
- The AgentCallbackLogin command? returns in ${AGENTBYCALLERID_${CALLERID}}: the ID of the successfully authorized agent.
- The ChanIsAvail command returns in ${AVAILCHAN}: the first available channel.
- The Dial command uses the value of the ${VXML_URL} variable: to send an XML URL to a Cisco 7960 phone.
- The Dial command uses the value of the ${ALERT_INFO} variable: to transmit call type information to Cisco phones.
- The Dial command returns in ${CAUSECODE}: the error code if the call failed.
- The Dial command returns in ${DIALSTATUS}: a text code representing the result of the last attempt to reach the subscriber.
- The Dial command uses the value of the ${TRANSFER_CONTEXT} variable: if this variable is set, it will be used to execute extension commands from the specified context during a call transfer (#transfer).
- The EnumLookup command returns in the ${ENUM} variable: the search result.
- The Hangup command uses the value of the ${PRI_CAUSE} variable to set PRI interface return codes.
- The MeetMe command uses the value of the {MEETME_AGI_BACKGROUND} variable: to determine the AGI script that needs to be executed.
- The MeetMe command returns in the ${MEETMESECS} variable: the number of seconds the user spent in the conference.
- The Playback command returns in the ${PLAYBACKSTATUS} variable: the result of the command execution (FAILED|SUCCESS).
- The Queue command returns in the ${QUEUESTATUS} variable: the reason why the call placed in the queue left it.
- The TXTLookup command returns in the ${TXTCIDNAME} variable: the DNS search result.
- The VoiceMail command returns in the ${VMSTATUS} variable: the result of the VoiceMail application execution?. Possible values: SUCCESS | USEREXIT | FAILED.
Macro-specific variables
When using contexts as macros, additional macro-specific "channel" variables are available.
- ${ARG1}: the first argument passed to the macro
- ${ARG2}: the second argument passed to the macro (and so on ...)
- ${MACRO_CONTEXT}: The name of the extension context that called this macro
- ${MACRO_EXTEN}: The extension that called this macro
- ${MACRO_OFFSET}: Set by the macro to determine the priority from which command execution will continue after the macro finishes
- ${MACRO_PRIORITY}: The priority of the extension at the time this macro was called
Environment variables
You can access Unix environment variables using the following syntax:
${ENV(''foo'')}
