text stringlengths 0 152 |
|---|
example would match from 9:00 A.M. to 5:59 P.M., on Monday through Friday, on any |
day of the month, in any month of the year: |
exten => s,1,NoOp() |
same => n,GotoIfTime(09:00-17:59,mon-fri,*,*?open,s,1) |
If the caller calls during these hours, the call will be sent to the first priority of the |
start extension in the context named open. If the call is made outside of the specified |
times, it will simply carry on with the next priority of the current extension. We’re |
going to add a new context named [closed] right after the pattern match example |
55512XX, and modify the [TestMenu] context we built in Chapter 6 to handle our |
new time condition. |
exten => _55512XX,1,Answer() |
same => n,Playback(tt-monkeys) |
same => n,Hangup() |
exten => *98,1,NoOp(Access voicemail retrieval.) |
same => n,VoiceMailMain() |
[closed] |
exten => start,1,Noop(after hours handler) |
same => n,Playback(go-away2) |
same => n,Hangup() |
[TestMenu] |
exten => start,1,Noop(main autoattendant) |
same => n,GotoIfTime(16:59-08:00,mon-fri,*,*?closed,start,1) |
same => n,GotoIfTime(11:59-09:00,sat,*,*?closed,start,1) |
same => n,GotoIfTime(00:00-23:59,sun,*,*?closed,start,1) |
same => n,Background(enter-ext-of-person) |
same => n,WaitExten(5) |
exten => 1,1,Dial(${UserA_DeskPhone},10) |
same => n,Playback(vm-nobodyavail) |
same => n,Hangup() |
174 |
| |
Chapter 10: Deeper into the Dialplan |
GoSub |
The GoSub() dialplan application allows you to send a call off to a separate section of |
the dialplan, make something useful happen, and then return the call to the point in |
the dialplan where it came from. You can pass arguments to GoSub(), and also receive |
a return code back from it. This cranks up the functionality of your dialplan quite a |
bit. |
Subroutines are a critical skill in any programming language, and |
no less so in an Asterisk dialplan. For those new to programming, a |
subroutine allows you to create a block of generic code that can be |
reused by different parts of the dialplan to avoid repetition. Think |
of it like a template in a word processing document, or a blank |
form, and you’ve got the general idea. Once you see them in opera‐ |
tion, it should become clear how useful they can be. |
Defining Subroutines |
There are no special naming requirements when using GoSub() in the dialplan. In |
fact, you can use GoSub() within the same context and extension if you want to. In |
most cases, however, your subroutines should be written in separate contexts: one |
context for each subroutine. When creating the context, we like to prepend the name |
with sub so we know the context is called from the GoSub() application. |
Let’s explore an obvious example of where a subroutine would be useful. |
As you might have noticed when we were building our sample dialplan for the users |
we have created, the dialplan logic for each user can require several lines of code. |
[sets] |
exten => 100,1,Dial(${UserA_DeskPhone},12) |
same => n,Voicemail(100@default) |
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail) |
same => n(unavail),VoiceMail(100@default,u) |
same => n,Hangup() |
same => n(busy),VoiceMail(100@default,b) |
same => n,Hangup() |
exten => 101,1,Dial(${UserA_SoftPhone}) |
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail) |
same => n(unavail),VoiceMail(101@default,u) |
same => n,Hangup() |
same => n(busy),VoiceMail(101@default,b) |
same => n,Hangup() |
exten => 102,1,Dial(${UserB_DeskPhone},10) |
GoSub |
| |
175 |
same => n,Playback(vm-nobodyavail) |
same => n,Hangup() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.