Page 159 - Asterisk™: The Future of Telephony
P. 159
slash, and the remote endpoint or resource. Common technology types include Zap
(for analog and T1/E1/J1 channels), SIP, and IAX2. For example, let’s assume that we
want to call a Zap endpoint identified by Zap/1, which is an FXS channel with an analog
phone plugged into it. The technology is Zap, and the resource is 1. Similarly, a call to
a SIP device (as defined in sip.conf) might have a destination of SIP/Jane, and a call to
an IAX device (defined in iax.conf) might have a destination of IAX2/Fred. If we wanted
Asterisk to ring the Zap/1 channel when extension 123 is reached in the dialplan, we’d
add the following extension:
exten => 123,1,Dial(Zap/1)
We can also dial multiple channels at the same time, by concatenating the destinations
with an ampersand (&), like this:
exten => 123,1,Dial(Zap/1&Zap/2&SIP/Jane)
The Dial() application will ring the specified destinations simultaneously, and bridge
the inbound call with whichever destination channel answers the call first. If the Dial
() application can’t contact any of the destinations, Asterisk will set a variable called
DIALSTATUS with the reason that it couldn’t dial the destinations, and continue on with
the next priority in the extension. *
The Dial() application also allows you to connect to a remote VoIP endpoint not pre-
viously defined in one of the channel configuration files. The full syntax for this type
of connection is:
Dial(technology/user[:password]@remote_host[:port][/remote_extension])
As an example, you can dial into a demonstration server at Digium using the IAX2
protocol by using the following extension:
exten => 500,1,Dial(IAX2/guest@misery.digium.com/s)
The full syntax for the Dial() application is slightly different when dealing with Zap
channels, as shown:
Dial(Zap/[gGrR]channel_or_group[/remote_extension])
For example, here is how you would dial 1-800-555-1212 on Zap channel number 4.
exten => 501,1,Dial(Zap/4/18005551212)
The second argument to the Dial() application is a timeout, specified in seconds. If a
timeout is given, Dial() will attempt to call the destination(s) for that number of sec-
onds before giving up and moving on to the next priority in the extension. If no timeout
is specified, Dial() will continue to dial the called channel(s) until someone answers
or the caller hangs up. Let’s add a timeout of 10 seconds to our extension:
exten => 123,1,Dial(Zap/1,10)
* Don’t worry, we’ll cover variables (in “Using Variables”) and show you how to have your dialplan make
decisions based on the value of this DIALSTATUS variable.
Building an Interactive Dialplan | 131