text
stringlengths
0
152
They may seem like a bit of a strange concept when you first start using them, but
believe us when we tell you they can be the answer to a problem you can’t figure out
any other way. You will almost certainly want to make use of them when you start
writing advanced dialplans. The best way to illustrate the use of local channels is
through an example. Let’s suppose we have a situation where we need to ring multiple
people, but we need to provide delays of different lengths before dialing each of the
members. The use of local channels is the solution to the problem.
Local Channels
|
177
With the Dial() application, you can certainly ring multiple endpoints (see extension
110 in your dialplan for an example of this), but all three channels will ring at the
same time, and for the same length of time.
exten => 110,1,Dial(${UserA_DeskPhone}&${UserA_SoftPhone}&${UserB_SoftPhone})
same => n,Hangup()
However, let’s say we want to introduce some delays prior to ringing a user, and also
stop ringing locations at different times. Using local channels gives us independent
control over each of the channels we want to dial, so we can introduce delays and
control the period of time for which each channel rings independently.
Let’s say we have a small company, where the receptionist is primarily responsible for
the incoming calls, but there are also two team members who are tasked with backing
up reception, and finally the owner wants to help out if need be too.
These are the requirements:
• The reception phone should ring right away, and keep ringing and not stop until
answered.
• The team member phones shouldn’t ring for the first 9 seconds, at which point
they can ring until answered.
• The owner’s phone should only ring if the call has gone on for 12 seconds with
no answer. Also, we’re pretending it’s a cell phone, and thus should stop ringing
18 seconds later so that the call is not answered by the cell phone voicemail.
We’ll use our existing configured channels to play the various roles. If you have any
way to do so, please try to have them all registered somewhere so they can all ring
when called. It’ll give you a much better idea of what’s going on when testing.7
This is a great time for a subroutine:
[subDialDelay]
exten => _[a-zA-Z0-9].,1,Noop(channel ${ARG1}, pre-delay ${ARG2}, timeout ${ARG3})
; same => n,Progress() ; Optional; Signals back that the call is proceeding
same => n,Wait(${ARG2}) ; how long to wait before dialing
same => n,Dial(${ARG1},${ARG3}) ; timeout can be blank (infinite)
same => n,Hangup()
You already have a subroutine at the bottom of the file. Add this
one down there too so all your subroutines end up grouped
together.
7 Obsolete Android phones and tablets can be great for this.
178
|
Chapter 10: Deeper into the Dialplan
Now we want a context in which we’ll build out the extensions to be used by the local
channel:
;LOCAL CHANNELS
[localDialDelay]
exten => receptionist,1,Gosub(subDialDelay,${EXTEN},1(${UserA_DeskPhone},0,600))
exten => team_one,1,Gosub(subDialDelay,${EXTEN},1(${UserA_SoftPhone},9,600))
exten => team_two,1,Gosub(subDialDelay,${EXTEN},1(${UserB_DeskPhone},9,600))
exten => owner,1,Gosub(subDialDelay,${EXTEN},1(${UserB_SoftPhone},12,18))
Even though the destination for a local channel is really just
dialplan—the same as you might jump to with a Goto()—these
constructs tend to be very special-purpose, and fit into the dialplan
better in their own area, down with the subroutines. That’s why we
named the context with the prefix local. It’s not required, but
makes things easier to make sense of.
Now we stitch it all together in our [sets] context.
First, let’s provide a way to dial each local channel individually, so we can sanity check
each one to be sure it’s doing what it should.
exten => 103,1,Gosub(subDialUser,${EXTEN},1(${UserB_SoftPhone},${EXTEN},default,24))
; These are for testing individually before we put them together
exten => 104,1,Dial(Local/receptionist@localDialDelay)
exten => 105,1,Dial(Local/team_one@localDialDelay)
exten => 106,1,Dial(Local/team_two@localDialDelay)
exten => 107,1,Dial(Local/owner@localDialDelay)