text stringlengths 0 152 |
|---|
you can actually pass either one, two, or three arguments to the |
application. If you pass a single argument, Asterisk will assume it’s |
the destination priority in the current extension. If you pass two |
arguments, Asterisk will treat them as the extension and the prior‐ |
ity to go to in the current context. |
In this example, we’ve passed all three arguments for the sake of |
clarity, but passing just the extension and priority would have had |
the same effect, since the destination context is the same as the |
source context. |
Handling Invalid Entries and Timeouts |
We need an extension for invalid entries. In Asterisk, when a context receives a |
request for an extension that is not valid within that context (e.g., pressing 9 in the |
preceding example), the call is sent to the i extension. We also need an extension to |
handle situations when the caller doesn’t give input in time (the default timeout is 10 |
seconds). Calls will be sent to the t extension if the caller takes too long to press a |
digit after WaitExten() has been called. Here is what our dialplan will look like after |
we’ve added these two extensions: |
[TestMenu] |
exten => start,1,Answer() |
same => n,Background(enter-ext-of-person) |
same => n,WaitExten(5) |
exten => 1,1,Playback(digits/1) |
same => n,Goto(TestMenu,start,1) |
exten => 2,1,Playback(digits/2) |
same => n,Goto(TestMenu,start,1) |
exten => i,1,Playback(pbx-invalid) |
same => n,Goto(TestMenu,start,1) |
exten => t,1,Playback(please-try-again) |
same => n,Goto(TestMenu,start,1) |
Using the i11 and t extensions makes our menu a little more robust and user-friendly. |
That being said, it is still quite limited, because outside callers still have no way of |
connecting to a live person. To do that, we’ll need to learn about the Dial() |
application. |
11 The i extension is for catching invalid entries supplied to a dialplan application such as Background(). It is |
not used for matching on invalidly dialed extensions or nonmatching pattern matches. |
92 |
| |
Chapter 6: Dialplan Basics |
Using the Dial() Application |
One of Asterisk’s most valuable features is its ability to connect different callers to |
each other. While Asterisk currently is used mostly for SIP connections, it supports a |
wide variety of channel types (from Analog to SS7, and various old VoIP protocols |
such as MGCP and SCCP). Asterisk takes much of the hard work out of connecting |
and translating between disparate networks. All you have to do is learn how to use |
the Dial() application. |
The syntax of the Dial() application is more complex than that of the other applica‐ |
tions we’ve used so far, but it’s also where much of the magic of Asterisk happens. |
Dial() takes up to four arguments, which we’ll look at next. |
The syntax of Dial() looks like this: |
Dial(Technology/Resource[&Technology2/Resource2[&...]][,timeout[,options[,URL]]]) |
Put simply, you tell Dial() what channel12 you want to send the call out to, and set a |
few options to tweak the behavior. The use of Dial() can get complex, but at its most |
basic, it’s that simple. |
Argument 1: destination |
The first argument is the destination you’re attempting to call, which (in its simplest |
form) is made up of a technology (or transport) across which to make the call, a for‐ |
ward slash, and the address of the remote endpoint or resource. |
These days, you’re most likely to be using PJSIP as your channel |
type, but in the not-too-distant past, common technology types |
also included DAHDI (for analog and T1/E1/J1 channels), the old |
SIP channel (prior to PJSIP), and IAX2.13 If you’re looking at an |
older dialplan, you may see some of these other protocols repre‐ |
sented. Going forward, only PJSIP and DAHDI are recommended |
and maintained. |
Let’s assume that we want to call one of our PJSIP channels named SOFTPHONE_B. The |
technology is PJSIP, and the resource (or channel) identifier is SOFTPHONE_B. Simi‐ |
larly, a call to a DAHDI device (defined in chan_dahdi.conf) might have a destination |
12 Or channels, if you want to ring more than one at a time. |
13 IAX2 (pronounced “EEKS”), is the Inter Asterisk Exchange protocol (v2). In the early days of Asterisk it was |
popular for trunking, as it greatly reduced signaling overhead on busy circuits. Bandwidth has become far less |
expensive, and SIP protocol has become nearly ubiquitous. The IAX2 protocol is no longer actively main‐ |
tained, but it still retains some popularity for its ability to traverse firewalls, and a few carriers might still sup‐ |
port it. However, its use is deprecated, and in fact discouraged. |
Building an Interactive Dialplan |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.