Skip to main content

mod_dptools: execute_extension

About

Execute an extension from within another extension and return. execute_extension executes an extension like a macro then returns, whereas transfer does not return. When you don't need to do anything else, use transfer and exit what you are doing and the channel goes back to the dialplan.

execute_extension will keep the current scope and build a one time extension, execute it, and return right back to where it was called from.

The transfer actually alters the channel's state, so if you are in a script you should exit the script as soon as you call transfer.

Note that this hunts through the entire specified dialplan, so all extensions in the target context are still checked for matches. Be careful to avoid loops and ambiguities.

Usage

<action application="execute_extension" data="extension [dialplan] [context]"/>

If you do not specify the dialplan and context, it defaults to the current one. Please note that the extension parameter indicates a value that will be matched by dialplan_hunt() as a destination_number. It will not match on the extension's name= value. See the is_transfer example below on how to match on a name.

Examples

<extension name="hold_music">
<condition field="destination_number" expression="^9999$"/>
<condition field="${sip_has_crypto}" expression="^(AES_CM_128_HMAC_SHA1_32|AES_CM_128_HMAC_SHA1_80)$">
<action application="answer"/>
<action application="execute_extension" data="is_secure XML features"/>
<action application="playback" data="$${moh_uri}"/>
<anti-action application="answer"/>
<anti-action application="playback" data="$${moh_uri}"/>
</condition>
</extension>

Another example is in features.xml:

<extension name="dx">
<condition field="destination_number" expression="^dx$">
<action application="answer"/>
<action application="read" data="11 11 'tone_stream://%(10000,0,350,440)' digits 5000 #"/>
<action application="execute_extension" data="is_transfer XML features"/>
</condition>
</extension>
<extension name="is_transfer">
<condition field="destination_number" expression="^is_transfer$"/>
<condition field="${digits}" expression="^(\d+)$">
<action application="transfer" data="-bleg ${digits} XML default"/>
<anti-action application="eval" data="w00t"/>
</condition>
</extension>

See Also