text stringlengths 0 152 |
|---|
exten => 102,1,Dial(PJSIP/0000f30B0B02,10,m) |
same => n,Playback(vm-nobodyavail) |
same => n,Hangup() |
Argument 4: URI |
The fourth and final argument to the Dial() application is a URI. If the destination |
channel supports receiving a URI at the time of the call, the specified URI will be sent |
(for example, if you have an IP telephone that supports receiving a URI, it will appear |
on the phone’s display; likewise, if you’re using a softphone, the URI might pop up on |
your computer screen). This argument is very rarely used. |
Building an Interactive Dialplan |
| |
95 |
Updating the dialplan |
Let’s modify extensions 1 and 2 in our menu to use the Dial() application, and add |
extensions 3 and 4 just for good measure: |
[TestMenu] |
exten => start,1,Answer() |
same => n,Background(enter-ext-of-person) |
same => n,WaitExten(5) |
exten => 1,1,Dial(PJSIP/0000f30A0A01,10) |
same => n,Playback(vm-nobodyavail) |
same => n,Hangup() |
exten => 2,1,Dial(PJSIP/0000f30B0B02,10) |
same => n,Playback(vm-nobodyavail) |
same => n,Hangup() |
exten => 3,1,Dial(PJSIP/SOFTPHONE_A,10) |
same => n,Playback(vm-nobodyavail) |
same => n,Hangup() |
exten => 4,1,Dial(PJSIP/SOFTPHONE_B,10) |
same => n,Playback(vm-nobodyavail) |
same => n,Hangup() |
exten => i,1,Playback(pbx-invalid) |
same => n,Goto(TestMenu,start,1) |
exten => t,1,Playback(vm-goodbye) |
same => n,Hangup() |
Blank arguments |
Note that the second, third, and fourth arguments may be left blank; only the first |
argument is required. For example, if you want to specify an option but not a time‐ |
out, simply leave the timeout argument blank, like this: |
exten => 4,1,Dial(SIP/SOFTPHONE_B,,m) |
Using Variables |
If you have programming experience, you already understand what a variable is. If |
not, we’ll briefly explain what variables are and how they are used. Any dialplan work |
beyond the very simple examples just given will greatly benefit from the use of vari‐ |
ables. They are one of the useful features of a customizable dialplan that you will not |
find in a typical proprietary PBX. |
A variable is a named container that can hold a value. Think of it like a post office |
box. The advantage of a variable is that its contents may change, but its name does |
not, which means you can write code that references the variable name and not worry |
about what the value will be. It is almost impossible to do any sort of useful program‐ |
ming without variables. |
96 |
| |
Chapter 6: Dialplan Basics |
There are two ways to reference a variable. To reference the variable’s name, simply |
type the name of the variable. If, on the other hand, you want to reference the value |
of the variable, you must type a dollar sign, an opening curly brace, the name of the |
variable, and a closing curly brace. So, to use the post office box analogy, you refer to |
the box itself by simply using its name, and you refer to the contents with the use of |
the ${} wrapper. A variable named MyVar is referred to as MyVar, and its contents are |
accessed with ${MyVar}. Here’s how we might use a variable inside the Dial() |
application:16 |
exten => 203,1,Noop(say some digits) |
same => n,Answer() |
same => n,Set(SomeDigits=123) |
same => n,SayDigits(${SomeDigits}) |
same => n,Wait(.25) |
same => n,Set(SomeDigits=543) |
same => n,SayDigits(${SomeDigits}) |
In our dialplan, whenever we refer to ${SomeDigits}, Asterisk will automatically |
replace it with whatever value has been assigned to the variable named SomeDigits. |
Note that variable names are case-sensitive. A variable named SOME |
DIGITS is different from a variable named SomeDigits. You should |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.