Chapter 14: Dialplan Application Reference
This chapter is a reference for the dialplan applications you invoke with <action application="..." data="..."/> inside an extension condition. It covers every application registered by mod_dptools, which provides the core call-control, audio, DTMF, variable, and logging applications. A handful of these are advanced or internal helpers (for example park_state, acknowledge_call, recovery_refresh, reuse_caller_profile, set_media_stats, capture_text, vad_test, and the video_* overlay apps) that operators rarely call directly; they are included here for completeness and noted as such. Applications provided by companion modules (mod_conference, mod_voicemail, mod_fifo, mod_valet_parking, mod_hash, mod_db, mod_lua, mod_spy, mod_esf, mod_fsv) are covered in the Feature Applications section; those modules must be loaded before the applications become available.
Call Control
These applications establish, route, and tear down call legs. They operate directly on the signaling and media state of the channel.
Scheduling Applications
These schedule deferred actions on the channel.
Audio and Prompts
These applications play, record, and generate audio on the channel. They require an answered (or at minimum early-media) channel unless stated otherwise.
DTMF and Signaling
These applications control how DTMF is detected, generated, and transmitted. Inband detection (start_dtmf) is required when the endpoint does not send RFC 2833 telephone-event packets.
Feature Applications
These applications are registered by companion modules. Each module must be loaded in modules.conf.xml for the application to be available.
Conferencing (mod_conference)
The conference application and its configuration are covered in detail in the Conferencing chapter.
Voicemail (mod_voicemail)
The voicemail application and its configuration are covered in detail in the Voicemail chapter.
| Application | Purpose | Arguments |
|---|---|---|
voicemail | Deliver a call to a voicemail box, or enter the mailbox check menu. | [check] [auth] <profile_name> <domain_name> [<id>] [uuid] |
FIFO Queuing (mod_fifo)
The fifo application and its configuration are covered in detail in the Queues: FIFO and Call Center chapter.
Valet Parking (mod_valet_parking)
The valet_park application and its configuration are covered in detail in the Utility Applications chapter.
In-Memory Hash Table (mod_hash)
SQLite Key-Value Store (mod_db)
| Application | Purpose | Arguments |
|---|---|---|
db | Insert or delete a key-value pair in the persistent SQLite-backed key-value store. Values survive restarts. | [insert|delete]/<realm>/<key>/<val> |
IVR Menu (mod_dptools)
| Application | Purpose | Arguments |
|---|---|---|
ivr | Run a named IVR menu defined in ivr_menus.conf.xml. | <menu_name> |
Lua Scripting (mod_lua)
| Application | Purpose | Arguments |
|---|---|---|
lua | Execute a Lua script in the context of the current call channel. | <script_path> [<args>] |
Call Limiting (mod_dptools)
Eavesdrop (mod_dptools)
User Spy (mod_spy)
| Application | Purpose | Arguments |
|---|---|---|
userspy | Continuously eavesdrop on all calls to a specific directory user. Cycles automatically as the user starts new calls. mod_spy must be loaded. | <user@domain> [uuid] |
Multicast Paging (mod_esf)
FSV Video Recording (mod_fsv)
Variables, Logging, and Meta-binding
These applications read and write channel variables, write to the log, and bind DTMF keys to mid-call actions.
Channel Variables
Logging and Diagnostics
DTMF Meta-binding
bind_meta_app lets the operator bind a DTMF digit (preceded by *) pressed during a bridged call to a dialplan application, without interrupting the media stream.
The second argument selects which leg detects the keypress (a, b, or ab). The third argument selects the execution scope: a = a-leg, b = b-leg, o = opposite leg, s = self, i = inline, 1 = once.
Miscellaneous Utilities
Examples
The following examples are drawn from the vanilla FreeSWITCH dialplan (default.xml and features.xml).
Answer, bridge, and fall back to voicemail
<extension name="Local_Extension">
<condition field="destination_number" expression="^(10[01][0-9])$">
<action application="export" data="dialed_extension=$1"/>
<action application="set" data="call_timeout=30"/>
<action application="set" data="hangup_after_bridge=true"/>
<action application="set" data="continue_on_fail=true"/>
<action application="bridge" data="user/${dialed_extension}@${domain_name}"/>
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="bridge" data="loopback/app=voicemail:default ${domain_name} ${dialed_extension}"/>
</condition>
</extension>
Bind meta-app keys to mid-call features
<action application="bind_meta_app" data="1 b s execute_extension::dx XML features"/>
<action application="bind_meta_app" data="2 b s record_session::${recordings_dir}/${caller_id_number}.wav"/>
<action application="bind_meta_app" data="3 b s execute_extension::cf XML features"/>
Intercept a ringing channel by UUID
<extension name="global-intercept">
<condition field="destination_number" expression="^886$">
<action application="answer"/>
<action application="intercept" data="${hash(select/${domain_name}-last_dial_ext/global)}"/>
<action application="sleep" data="2000"/>
</condition>
</extension>
Place a call into a conference room
<extension name="nb_conferences">
<condition field="destination_number" expression="^(30\d{2})$">
<action application="answer"/>
<action application="conference" data="$1-${domain_name}@default"/>
</condition>
</extension>
Park a call in a FIFO queue and retrieve it
<!-- Park -->
<extension name="park">
<condition field="destination_number" expression="^5900$">
<action application="set" data="fifo_music=${hold_music}"/>
<action application="fifo" data="5900@${domain_name} in"/>
</condition>
</extension>
<!-- Retrieve -->
<extension name="unpark">
<condition field="destination_number" expression="^5901$">
<action application="answer"/>
<action application="fifo" data="5900@${domain_name} out nowait"/>
</condition>
</extension>
Read digits and transfer
<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>
Valet parking
<!-- Park a call interactively -->
<extension name="valet_park">
<condition field="destination_number" expression="^(6000)$">
<action application="answer"/>
<action application="valet_park" data="valet_parking_lot ask 1 11 10000 ivr/ivr-enter_ext_pound.wav"/>
</condition>
</extension>
<!-- Park or retrieve by slot number (6001-6099) -->
<extension name="valet_park">
<condition field="destination_number" expression="^((?!6000)60\d{2})$">
<action application="answer"/>
<action application="valet_park" data="valet_parking_lot $1"/>
</condition>
</extension>
Log a warning and send a custom SIP response
<action application="log" data="WARNING Call from ${caller_id_number} exceeded limit"/>
<action application="respond" data="503 Service Unavailable"/>
Eavesdrop on all active channels
<extension name="eavesdrop">
<condition field="destination_number" expression="^779$">
<action application="answer"/>
<action application="set" data="eavesdrop_indicate_failed=tone_stream://%(500,0,320)"/>
<action application="set" data="eavesdrop_indicate_new=tone_stream://%(500,0,620)"/>
<action application="set" data="eavesdrop_indicate_idle=tone_stream://%(250,0,920)"/>
<action application="eavesdrop" data="all"/>
</condition>
</extension>
Dial Strings and Call Origination
A dial string is the argument passed to bridge, originate, and gateway destination fields. It describes one or more outbound legs to create, using endpoint prefixes, optional per-leg or global channel variables, and multi-leg separators. The parsing logic resides in switch_ivr_originate.c.
Endpoint Prefixes
Every leg in a dial string begins with an endpoint prefix that selects the channel driver. The prefix is separated from the address by a forward slash.
| Prefix | Meaning | Example |
|---|---|---|
user/<u>@<d> | Look up user <u> in domain <d> in the directory and dial the dial-string param from that user's profile. Domain is optional; defaults to the configured default domain. | user/1001@example.com |
sofia/<profile>/<uri> | Dial a SIP URI directly via the named sofia profile. | sofia/internal/1001@192.168.1.10 |
sofia/gateway/<gw>/<number> | Dial <number> through the named gateway. The gateway must be registered under any loaded sofia profile. | sofia/gateway/mycarrier/15551234567 |
loopback/<exten>[/<context>[/<dialplan>]] | Re-enter the dialplan at <exten> in <context> (default default) using <dialplan> (default xml). Also accepts loopback/app=<app>[:<arg>] to execute a specific application. | loopback/1001/default |
group/<name>@<domain> | Dial all members of a directory group simultaneously, using each member's dial-string. | group/support@example.com |
error/<cause> | Immediately return the named Q.850 hangup cause without placing any call. Useful as a fallback leg. | error/USER_BUSY |
pickup/<key> | Register the originating call into a named pickup group and wait. Any party that runs the pickup app with the same key will intercept the call. | pickup/sales |
Multi-leg Separators
A single dial string argument may describe multiple legs. Two separators control how those legs are dialed.
| Separator | Behavior | Where parsed |
|---|---|---|
, (comma) | Simultaneous (parallel) originate. All legs separated by commas within one group are dialed at the same time; the first to answer wins. | switch_separate_string with ',' inside each pipe-separated group |
| (pipe character) | Sequential (failover) originate. Groups separated by the pipe character are tried in order; the next group is attempted only if every leg in the current group fails or times out. | switch_separate_string with '|' at the top level |
:_: | Enterprise parallel originate (SWITCH_ENT_ORIGINATE_DELIM). Each leg separated by :_: is dispatched in its own thread concurrently, with independent ringback and timeout tracking. Use when the legs may have very different media behavior. | Detected by strstr before any other parsing; routes to switch_ivr_enterprise_originate |
Precedence. The string is first tested for :_:. If found, the enterprise originate path handles it. Otherwise the string is split by the pipe character into sequential groups, and each group is split by commas into simultaneous legs.
Channel Variable Syntax
Variables can be injected into a dial string at two scopes.
Global variables {key=val,key2=val2} -- prefixed before the first leg address, inside curly braces. These variables are applied to every leg in the entire dial string. Multiple sets of curly braces are allowed and merged in order. Parsed by switch_event_create_brackets with { and } as delimiters.
{ignore_early_media=true,origination_caller_id_number=5550000}sofia/internal/1001@pbx.example.com
Per-leg variables [key=val,key2=val2] -- prefixed immediately before the address of a single leg, inside square brackets. These variables apply only to the leg they precede and override any global variable with the same name for that leg only. Parsed by switch_event_create_brackets with [ and ] as delimiters.
[leg_timeout=10]sofia/internal/1001@pbx.example.com,[leg_timeout=20]sofia/internal/1002@pbx.example.com
Multiple [...] blocks may precede a single leg address; they are merged left to right.
Combined example. Global variable sets call timeout for all legs; per-leg variables override the timeout for individual legs.
{call_timeout=30}[leg_timeout=10]sofia/internal/1001@pbx,[leg_timeout=20]sofia/internal/1002@pbx
Worked bridge Examples
Failover: gateway first, then voicemail
Try the PSTN gateway for 30 seconds. If it fails, loop back into the dialplan and drop the caller into voicemail. continue_on_fail=true is required for the dialplan to continue after a failed bridge.
<extension name="outbound_with_voicemail_fallback">
<condition field="destination_number" expression="^(15551234567)$">
<action application="set" data="continue_on_fail=true"/>
<action application="set" data="call_timeout=30"/>
<action application="bridge" data="sofia/gateway/mycarrier/$1"/>
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="bridge" data="loopback/app=voicemail:default ${domain_name} 1000"/>
</condition>
</extension>
Simultaneous ring of two users
Ring user/1001 and user/1002 at the same time. The first to answer is bridged; the other leg is hung up automatically.
<action application="bridge" data="user/1001@${domain_name},user/1002@${domain_name}"/>
Sequential failover with simultaneous ring
Ring 1001 and 1002 simultaneously. If both fail, try the gateway. The pipe character separates the two groups.
<action application="bridge"
data="user/1001@${domain_name},user/1002@${domain_name}|sofia/gateway/mycarrier/15559990000"/>
Call Transfers and Feature Codes
Blind Transfer: the transfer Application
transfer immediately redirects the current channel to a new dialplan extension without consulting the destination first. The caller is transferred and the current dialplan execution ends.
<action application="transfer" data="<exten> [<dialplan> <context>]"/>
Optional flags modify which leg is transferred:
-bleg <exten> [<dialplan> <context>]-- transfer the B-leg (called party) instead of the A-leg.-both <exten> [<dialplan> <context>]-- transfer both legs independently to the same extension.
These flags are verified in transfer_function in mod_dptools.c.
Attended Transfer: att_xfer
att_xfer initiates an attended transfer. It puts the current B-leg on soft hold, dials the transfer target, bridges the operator to the target for consultation, and then completes the transfer when the operator hangs up.
<action application="att_xfer" data="<channel_url>"/>
The <channel_url> argument accepts any valid dial string (e.g., user/1002@${domain_name}).
DTMF keys during consultation. Three channel variables control what DTMF digits the operator presses while bridged to the transfer target:
Set these on the channel before calling att_xfer, or set them on the transfer target leg using per-leg variable syntax.
Result variable. After att_xfer completes, the channel variable att_xfer_result is set to success or failure (SWITCH_ATT_XFER_RESULT_VARIABLE in switch_types.h).
Vanilla dialplan binding. In features.xml, the att_xfer extension collects a digit sequence with read, sets origination_cancel_key on the originate call (note: this is the variable checked by originate, not by att_xfer itself; the att_xfer cancel key is attxfer_cancel_key), then calls att_xfer:
<extension name="att_xfer">
<condition field="destination_number" expression="^att_xfer$">
<action application="read" data="3 4 'tone_stream://%(10000,0,350,440)' digits 30000 #"/>
<action application="set" data="origination_cancel_key=#"/>
<action application="att_xfer" data="user/${digits}@$${domain}"/>
</condition>
</extension>
Three-way Calling: three_way
three_way bridges a third party UUID into the current call, creating a three-way audio mix using the existing bridged legs plus the channel identified by UUID. All three parties hear each other.
<action application="three_way" data="<uuid>"/>
The UUID must be an active session. The application is registered in mod_dptools.c.
Call Pickup
Pickup groups allow a ringing call to be answered by any party in a group. The mechanism uses two sides:
Registering a call into a group. Include pickup/<key> as one of the legs in a bridge dial string. When the bridge is established, the call is registered in the named pickup group using an in-memory hash. The pickup leg waits silently until claimed.
<action application="bridge"
data="user/${dialed_extension}@${domain_name},pickup/${called_party_callgroup}@${domain_name}"/>
Claiming a ringing call. The pickup application retrieves the first available call registered under the named key and bridges it to the current channel.
<action application="pickup" data="<key>"/>
Intercepting by UUID. The intercept application pulls any ringing or held channel into the current call by its UUID.
<action application="intercept" data="[-bleg] <uuid>"/>
The -bleg flag intercepts the B-leg of the identified session rather than the A-leg. The intercept: prefix is also used internally by mod_sofia when handling SIP REFER with Replaces headers, routing calls as answer,intercept:<uuid>.
In-call Feature Codes via bind_meta_app
bind_meta_app binds a single DTMF digit (pressed as *<digit> during a bridge) to a dialplan application without interrupting the media stream. Bindings are set before the bridge call and remain active for the duration of the bridge.
Syntax recap (from Section 5):
bind_meta_app <key> [a|b|ab] [a|b|o|s|i|1] <app>[::args]
- Argument 2: which leg detects the keypress.
a= A-leg only,b= B-leg only,ab= both. - Argument 3: which leg executes the app.
a= A-leg,b= B-leg,o= opposite leg,s= same leg,i= inline (current thread),1= once (remove binding after first trigger).
Vanilla bindings from default.xml. The Local_Extension extension sets these four bindings before every bridge:
| Keypress | Binding | Effect |
|---|---|---|
*1 | execute_extension::dx XML features | Prompt the B-leg caller to enter a number for a blind transfer. |
*2 | record_session::<path>.wav | Start recording the session to a timestamped file. |
*3 | execute_extension::cf XML features | Transfer both legs to a conference room. |
*4 | execute_extension::att_xfer XML features | Initiate an attended transfer from the B-leg. |
All four use b s (B-leg detects, same-leg executes).
Worked Example: Bridged Call with Feature Codes
The following extension replicates the vanilla Local_Extension pattern. It binds four in-call feature codes, then bridges to the dialed user. On failure it falls through to voicemail.
<extension name="Local_Extension">
<condition field="destination_number" expression="^(10[01][0-9])$">
<action application="export" data="dialed_extension=$1"/>
<!-- Feature code bindings active during the bridge -->
<action application="bind_meta_app" data="1 b s execute_extension::dx XML features"/>
<action application="bind_meta_app" data="2 b s record_session::${recordings_dir}/${caller_id_number}.wav"/>
<action application="bind_meta_app" data="3 b s execute_extension::cf XML features"/>
<action application="bind_meta_app" data="4 b s execute_extension::att_xfer XML features"/>
<action application="set" data="call_timeout=30"/>
<action application="set" data="hangup_after_bridge=true"/>
<action application="set" data="continue_on_fail=true"/>
<!-- Primary bridge; includes a pickup group leg for call-pickup by colleagues -->
<action application="bridge" data="user/${dialed_extension}@${domain_name}"/>
<!-- Fallback: voicemail -->
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="bridge" data="loopback/app=voicemail:default ${domain_name} ${dialed_extension}"/>
</condition>
</extension>
When a bridged B-leg party presses *4, execute_extension::att_xfer XML features runs in the features context. That extension collects a destination number with read, then calls att_xfer to consult the transfer target. The operator presses # (default attxfer_cancel_key) to abort, * (default attxfer_hangup_key) to complete the transfer, or 0 (default attxfer_conf_key) to merge all three parties.