Asterisk dialplan functions: Difference between revisions
(→SHARED) |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Overview == | == Overview == | ||
Asterisk dialplan function 내용 정리 | Asterisk dialplan function 내용 정리 | ||
== AES_DECRYPT == | |||
Decrypt a string encoded in base64 with AES given a 16 character key. | |||
Returns the plain text string. | |||
<pre> | |||
AES_DECRYPT(key,string) | |||
</pre> | |||
* key : AES key. | |||
* string : Input string. | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AES_DECRYPT | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AES_ENCRYPT | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_BASE64_ENCODE | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_BASE64_DECODE | |||
== AES_ENCRYPT == | |||
Encrypt a string with AES given a 16 character key. | |||
Return an AES encrypted string encoded in base64. | |||
<pre> | |||
AES_ENCRYPT(key,string) | |||
</pre> | |||
* key : AES key. | |||
* string : Input string. | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AES_ENCRYPT | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AES_DECRYPT | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_BASE64_ENCODE | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_BASE64_DECODE | |||
== AGC == | |||
Apply automatic gain control to audio on a channel. | |||
The AGC function will apply automatic gain control to the audio on the channel that it is executed on. Using rx for audio received and tx for audio transmitted to the channel. When using this function you set a target audio level. It is primarily intended for use with analog lines, but could be useful for other channels as well. The target volume is set with a number between 1 - 32768. The larger the number the louder(more gain) the channel will receive. | |||
<pre> | |||
AGC(channeldirection) | |||
</pre> | |||
* channeldirection : this can be either rx or tx. | |||
=== Example === | |||
<pre> | |||
exten => 1,1,Set(AGC(rx)=8000) | |||
exten => 1,2,Set(AGC(tx)=off) | |||
</pre> | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AGC | |||
== AGENT == | |||
Gets information about an Agent. | |||
<pre> | |||
AGENT(AgentId:item) | |||
</pre> | |||
* AgentId | |||
* item : The valid items to retrieve are: | |||
: status : (default) The status of the agent (LOGGEDIN | LOGGEDOUT) | |||
: password : Deprecated. The dialplan handles any agent authentication. | |||
: name : The name of the agent. | |||
: mohclass : MusicOnHold class. | |||
: channel : The name of the active channel for the Agent(AgentLogin). | |||
: fullchannel : The untruncated name of the active channel for the Agent(AgentLogin). | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AGENT | |||
== GROUP == | |||
Gets or sets the channel group. | |||
Category can be employed for more fine grained group management. Each channel can only be member of exactly one group per category. | |||
<pre> | |||
GROUP(category) | |||
</pre> | |||
* category : Category name. | |||
=== Example === | |||
<pre> | |||
[CountOutgoingCalls] | |||
exten => s,1,Set(GROUP(active_calls)=active_calls) | |||
same => n,GotoIf($[${GROUP_COUNT(active_calls)}>${OutgoingCallLines}]?FraudHandler,s-668,1) ; Too many concurrent calls (outbound only). | |||
same => n,Return() | |||
</pre> | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_GROUP | |||
== GROUP_COUNT == | |||
Counts the number of channels in the specified group. | |||
Calculates the group count for the specified group, or uses the channel's current group if not specified (and non-empty). | |||
<pre> | |||
GROUP_COUNT(groupname@category) | |||
</pre> | |||
* groupname : Group name. | |||
* category : Category name. | |||
=== Example === | |||
<pre> | |||
[CountOutgoingCalls] | |||
exten => s,1,Set(GROUP(active_calls)=active_calls) | |||
same => n,GotoIf($[${GROUP_COUNT(active_calls)}>${OutgoingCallLines}]?FraudHandler,s-668,1) ; Too many concurrent calls (outbound only). | |||
same => n,Return() | |||
</pre> | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_GROUP_COUNT | |||
== GROUP_LIST == | |||
Gets a list of the groups set on a channel. | |||
<pre> | |||
GROUP_LIST() | |||
</pre> | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_GROUP_LIST | |||
== GROUP_MATCH_COUNT == | |||
Counts the number of channles in the groups matching the specified pattern. | |||
Calculates the group count for all groups that match the specified pattern. Note: category matching is applied after matching based on group. Uses standard regular expression matching on both. | |||
<pre> | |||
GROUP_MATCH_COUNT(groupmatch@category) | |||
</pre> | |||
* groupmatch : A standard regular expression used to match a group name. | |||
* category : A standard regular expression used to match a category name. | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_GROUP_MATCH_COUNT | |||
== IMPORT == | |||
Retrieve the value of a variable from another channel. | |||
<pre> | |||
IMPORT(channel,variable) | |||
</pre> | |||
* channel | |||
* variable | |||
=== Example === | |||
<pre> | |||
[TransferFromMVNO] | |||
exten => _[+*0-9a-zA-Z]!,2,NoOp(Transfer from MVNO) | |||
same => n,Set(__InternalNumber=${IMPORT(${SHARED(TransferChennel)},InternalNumber)}) | |||
... | |||
</pre> | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_IMPORT | |||
== PJSIP_HEADER == | |||
Gets, adds, updates or removes the specified SIP header from a PJSIP session. | |||
<pre> | |||
PJSIP_HEADER(action,name[,number]) | |||
</pre> | |||
* action | |||
: read: Returns instance number of header name. | |||
: add: Adds a new header name to this session. | |||
: update: Updates instance number of header name to a new value. The header must already exist. | |||
: remove: Removes all instances of previously added headers whose names match name. A {} may be appended to name to remove all headers *beginning with name. name may be set to a single {} to clear *all previously added headers. In all cases, the number of headers actually removed is returned. | |||
* name: The name of the header. | |||
* number: If there's more than 1 header with the same name, this specifies which header to read or update. If not specified, defaults to 1 meaning the first matching header. Not valid for add or remove. | |||
=== Example === | |||
<pre> | |||
[voip-handle] | |||
exten => _[+0-9].,1,Verbose(Sending channel to stasis app.) | |||
same => n,Stasis(pchero_voip,SIP_CALL_ID=${PJSIP_HEADER(read,Call-ID)}) | |||
same => n,Goto(hangupsub,s,1) | |||
</pre> | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+Function_PJSIP_HEADER | |||
== SHARED == | |||
Gets or sets the shared variable specified. | |||
Implements a shared variable area, in which you may share variables between channels. | |||
The variables used in this space are separate from the general namespace of the channel and thus SHARED(foo) and foo represent two completely different variables, despite sharing the same name. | |||
Finally, realize that there is an inherent race between channels operating at the same time, fiding with each others internal variables, which is why this special variable namespace exists; it is to remind you that variables in the SHARED namespace may change at any time, without warning. You should therefore take special care to ensure that when using the SHARED namespace, you retrieve the variable and store it in a regular channel variable before using it in a set of calculations(or you might be surprised by the result). | |||
<pre> | |||
SHARED(varname,channel) | |||
</pre> | |||
* varname : Variable name | |||
* channel : If not specified will default to current channel. It is the complete channel name: SIP/12-abcd1234 or the prefix only SIP/12. | |||
=== Example === | |||
<pre> | |||
[SetSharedVariables] | |||
exten => s,1,NoOp(Set shared variables) | |||
same => n,Set(SHARED(DirectNumber)=${DirectNumber}) | |||
same => n,Set(SHARED(InternalNumber)=${DirectNumber}) | |||
... | |||
</pre> | |||
=== See also === | |||
* https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_SHARED | |||
== TIMEOUT == | |||
=== Example === | |||
<pre> | |||
exten => _[+0-9a-zA-Z].,1,NoOp(test) | |||
same => n,Set(TIMEOUT(absolute)=600) | |||
same => n,Stasis(test) | |||
</pre> | |||
== VALID_EXTEN == | == VALID_EXTEN == |
Latest revision as of 19:51, 3 May 2020
Overview
Asterisk dialplan function 내용 정리
AES_DECRYPT
Decrypt a string encoded in base64 with AES given a 16 character key.
Returns the plain text string.
AES_DECRYPT(key,string)
- key : AES key.
- string : Input string.
See also
- https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AES_DECRYPT
- https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AES_ENCRYPT
- https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_BASE64_ENCODE
- https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_BASE64_DECODE
AES_ENCRYPT
Encrypt a string with AES given a 16 character key.
Return an AES encrypted string encoded in base64.
AES_ENCRYPT(key,string)
- key : AES key.
- string : Input string.
See also
- https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AES_ENCRYPT
- https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_AES_DECRYPT
- https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_BASE64_ENCODE
- https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_BASE64_DECODE
AGC
Apply automatic gain control to audio on a channel.
The AGC function will apply automatic gain control to the audio on the channel that it is executed on. Using rx for audio received and tx for audio transmitted to the channel. When using this function you set a target audio level. It is primarily intended for use with analog lines, but could be useful for other channels as well. The target volume is set with a number between 1 - 32768. The larger the number the louder(more gain) the channel will receive.
AGC(channeldirection)
- channeldirection : this can be either rx or tx.
Example
exten => 1,1,Set(AGC(rx)=8000) exten => 1,2,Set(AGC(tx)=off)
See also
AGENT
Gets information about an Agent.
AGENT(AgentId:item)
- AgentId
- item : The valid items to retrieve are:
- status : (default) The status of the agent (LOGGEDIN | LOGGEDOUT)
- password : Deprecated. The dialplan handles any agent authentication.
- name : The name of the agent.
- mohclass : MusicOnHold class.
- channel : The name of the active channel for the Agent(AgentLogin).
- fullchannel : The untruncated name of the active channel for the Agent(AgentLogin).
See also
GROUP
Gets or sets the channel group.
Category can be employed for more fine grained group management. Each channel can only be member of exactly one group per category.
GROUP(category)
- category : Category name.
Example
[CountOutgoingCalls] exten => s,1,Set(GROUP(active_calls)=active_calls) same => n,GotoIf($[${GROUP_COUNT(active_calls)}>${OutgoingCallLines}]?FraudHandler,s-668,1) ; Too many concurrent calls (outbound only). same => n,Return()
See also
GROUP_COUNT
Counts the number of channels in the specified group.
Calculates the group count for the specified group, or uses the channel's current group if not specified (and non-empty).
GROUP_COUNT(groupname@category)
- groupname : Group name.
- category : Category name.
Example
[CountOutgoingCalls] exten => s,1,Set(GROUP(active_calls)=active_calls) same => n,GotoIf($[${GROUP_COUNT(active_calls)}>${OutgoingCallLines}]?FraudHandler,s-668,1) ; Too many concurrent calls (outbound only). same => n,Return()
See also
GROUP_LIST
Gets a list of the groups set on a channel.
GROUP_LIST()
See also
GROUP_MATCH_COUNT
Counts the number of channles in the groups matching the specified pattern.
Calculates the group count for all groups that match the specified pattern. Note: category matching is applied after matching based on group. Uses standard regular expression matching on both.
GROUP_MATCH_COUNT(groupmatch@category)
- groupmatch : A standard regular expression used to match a group name.
- category : A standard regular expression used to match a category name.
See also
IMPORT
Retrieve the value of a variable from another channel.
IMPORT(channel,variable)
- channel
- variable
Example
[TransferFromMVNO] exten => _[+*0-9a-zA-Z]!,2,NoOp(Transfer from MVNO) same => n,Set(__InternalNumber=${IMPORT(${SHARED(TransferChennel)},InternalNumber)}) ...
See also
PJSIP_HEADER
Gets, adds, updates or removes the specified SIP header from a PJSIP session.
PJSIP_HEADER(action,name[,number])
- action
- read: Returns instance number of header name.
- add: Adds a new header name to this session.
- update: Updates instance number of header name to a new value. The header must already exist.
- remove: Removes all instances of previously added headers whose names match name. A {} may be appended to name to remove all headers *beginning with name. name may be set to a single {} to clear *all previously added headers. In all cases, the number of headers actually removed is returned.
- name: The name of the header.
- number: If there's more than 1 header with the same name, this specifies which header to read or update. If not specified, defaults to 1 meaning the first matching header. Not valid for add or remove.
Example
[voip-handle] exten => _[+0-9].,1,Verbose(Sending channel to stasis app.) same => n,Stasis(pchero_voip,SIP_CALL_ID=${PJSIP_HEADER(read,Call-ID)}) same => n,Goto(hangupsub,s,1)
See also
SHARED
Gets or sets the shared variable specified.
Implements a shared variable area, in which you may share variables between channels.
The variables used in this space are separate from the general namespace of the channel and thus SHARED(foo) and foo represent two completely different variables, despite sharing the same name.
Finally, realize that there is an inherent race between channels operating at the same time, fiding with each others internal variables, which is why this special variable namespace exists; it is to remind you that variables in the SHARED namespace may change at any time, without warning. You should therefore take special care to ensure that when using the SHARED namespace, you retrieve the variable and store it in a regular channel variable before using it in a set of calculations(or you might be surprised by the result).
SHARED(varname,channel)
- varname : Variable name
- channel : If not specified will default to current channel. It is the complete channel name: SIP/12-abcd1234 or the prefix only SIP/12.
Example
[SetSharedVariables] exten => s,1,NoOp(Set shared variables) same => n,Set(SHARED(DirectNumber)=${DirectNumber}) same => n,Set(SHARED(InternalNumber)=${DirectNumber}) ...
See also
TIMEOUT
Example
exten => _[+0-9a-zA-Z].,1,NoOp(test) same => n,Set(TIMEOUT(absolute)=600) same => n,Stasis(test)
VALID_EXTEN
입력된 Extension 이 지정된 Context 에 존재하는지 여부를 확인한다.
Determine whether an extension exists or not.
Returns a true value if the indicated context, extension, and priority exist.
- This function has been deprecated in favor of the DIALPLAN_EXISTS() function.
VALID_EXTEN(context,extension,priority)
- context : Defaults to the current context.
- extension
- priority : Priority defaults to 1
Example
[DialToInternal] include => Internal exten => s,1,Goto(${CallFlowID},1) exten => _[+0-9]!,1,GoSub(LoopDetection,s,1) same => n,ExecIf(${ISNULL(${UniqueID})}?Set(__UniqueID=${UNIQUEID})) same => n,Log(NOTICE,${UniqueID}-${CONTEXT}(${UNIQUEID}@${CHANNEL})) same => n,GotoIf(${VALID_EXTEN(Internal,${EXTEN},1)}?Internal,${EXTEN},1)
See also
See also
- https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Dialplan+Functions - Asterisk 14 Dialplan Functions