** Pre-Dial Handlers were added in **Asterisk 11
Pre-dial handlers allow you to execute a dialplan subroutine on a channel before a call is placed but after the application performing a dial action is invoked. This means that the handlers are executed after the creation of the caller/callee channels, but before any actions have been taken to actually dial the callee channels. You can execute a dialplan subroutine on the caller channel and on each callee channel dialed.
There are two ways in which a pre-dial handler can be invoked:
- The 'B' option in an application executes a dialplan subroutine on the caller channel before any callee channels are created.
- The 'b' option in an application executes a dialplan subroutine on each callee channel after it is created but before the call is placed to the end-device.
* As pre-dial handlers are implemented using Gosub subroutines, they must be terminated with a call to Return. * Taking actions in pre-dial handlers that would put the caller/callee channels into other applications will result in undefined behaviour. Pre-dial handlers should be short routines that do not impact the state that the dialing application assumes the channel will be in.
If context or exten are not supplied then the current values from the caller channel are used.
The examples illustrated below use the following channels:
- SIP/foo is calling either SIP/bar, SIP/baz, or both
- SIP/foo is the caller
- SIP/bar is a callee
- SIP/baz is another callee
Example 1 - Executing a pre-dial handler on the caller channel¶
Example 1 CLI Output
Example 2 - Executing a pre-dial handler on a callee channel¶
Example 2 CLI Output
Example 3 - Executing a pre-dial handler on multiple callee channels¶
Example 3 CLI Output
<SIP/bar-124> Executing default,callee_handler,1
<SIP/bar-124> In callee pre-dial handler!
<SIP/baz-125> Executing default,callee_handler,1
<SIP/baz-125> In callee pre-dial handler!
<SIP/foo-123> calling SIP/bar-124
<SIP/foo-123> calling SIP/baz-125