text
stringlengths
0
152
|
93
of DAHDI/14169671111. If we wanted Asterisk to ring the PJSIP/SOFTPHONE_B chan‐
nel when extension 103 is reached in the dialplan, we’d add the following extension:
exten => 101,1,Dial(PJSIP/SOFTPHONE_A)
exten => 103,1,Dial(PJSIP/SOFTPHONE_B)
exten => 200,1,Answer()
We can also dial multiple channels at the same time, by concatenating the destina‐
tions with an ampersand (&), like this:
exten => 101,1,Dial(PJSIP/SOFTPHONE_A)
exten => 103,1,Dial(PJSIP/SOFTPHONE_B)
exten => 110,1,Dial(PJSIP/0000f30A0A01&PJSIP/SOFTPHONE_A&PJSIP/SOFTPHONE_B)
exten => 200,1,Answer()
The Dial() application will ring all of the specified destinations simultaneously, and
bridge the inbound call with whichever destination channel answers first (the other
channels will immediately stop ringing). 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 with the next priority in the extension.14
The Dial() application also allows you to connect to a remote VoIP endpoint not
previously defined in one of the channel configuration files. The full syntax is:
Dial(technology/user[:password]@remote_host[:port][/remote_extension])
The full syntax for the Dial() application is slightly different for DAHDI channels:
Dial(DAHDI/[gGrR]channel_or_group[/remote_extension])
For example, here is how you would dial 1-800-555-1212 on DAHDI channel num‐
ber 4:15
exten => 501,1,Dial(DAHDI/4/18005551212)
Argument 2: timeout
The second argument to the Dial() application is a timeout, specified in seconds. If a
timeout is given, Dial() will attempt to call the specified destination(s) for that num‐
ber of seconds 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
14 We’ll cover variables in the section “Using Variables” on page 96. In future chapters we’ll discuss how to have
your dialplan make decisions based on the value of DIALSTATUS.
15 Bear in mind that this assumes that this channel connects to something that knows how to reach external
numbers.
94
|
Chapter 6: Dialplan Basics
someone answers or the caller hangs up. Let’s add a timeout of 10 seconds to our
extension:
exten => 101,1,Dial(PJSIP/SOFTPHONE_A)
exten => 102,1,Dial(PJSIP/0000f30B0B02,10)
exten => 103,1,Dial(PJSIP/SOFTPHONE_B)
If the call is answered before the timeout, the channels are bridged and the dialplan is
done. If the destination simply does not answer, is busy, or is otherwise unavailable,
Asterisk will set a variable called DIALSTATUS and then continue on with the next pri‐
ority in the extension.
Let’s put what we’ve learned so far into another example:
exten => 102,1,Dial(PJSIP/0000f30B0B02,10)
same => n,Playback(vm-nobodyavail)
same => n,Hangup()
As you can see, this example will play the vm-nobodyavail.gsm sound file if the call
goes unanswered (and then hang up). Note that this doesn’t actually provide voice‐
mail; we’re just playing a prompt, which could have been any valid prompt. We’ll
cover sending calls to voicemail later.
Argument 3: option
The third argument to Dial() is an option string. It may contain one or more charac‐
ters that modify the behavior of the Dial() application. While the list of possible
options is too long to cover here, one of the most popular is the m option. If you place
the letter m as the third argument, the calling party will hear hold music instead of
ringing while the destination channel is being called (assuming, of course, that music
on hold has been configured correctly). To add the m option to our last example, we
simply change the first line: