[Asterisk-Users] Very complicated dialplans?

Andrew Kohlsmith akohlsmith-asterisk at benshaw.com
Sat Aug 6 08:15:01 MST 2005


On Friday 05 August 2005 21:10, Arik Funke wrote:
> how can I implement a dial plan like the following:

Well you've scripted it out very clearly... now just use the dialplan 
applications and make it exactly as you've said.

> 1. ring phones 1,2,3 monday to friday between 9:00 and 20:00; if no
> answer after 15 sec also ring phones 4 and 5

I'd define some variables.  Say Phones 1, 2 and 3 are on Zap channels 1, 2 and 
3, and that Phone 4 and 5 are IAX phones.

PHONE1=Zap/1
PHONE2=Zap/2
PHONE3=Zap/3
PHONE4=IAX2/phone4
PHONE5=IAX2/phone5

I'm assuming that the call is coming in on Zap channel 4 and you're not 
getting an extension # (DID) from the telco so the extension you'll hit is 
the 's' extension:

exten => s,1,GotoIfTime(9:00-20:00|mon-fri|*|*?nine2eight,s,1)

> 2. ring phone 1 monday to friday between 0:00-9:00 and 20:00-24:00; if
> no answer after 20 sec also ring phones 2 and 3

exten => s,2,GotoIfTime(0:00-9:00|mon-fri|*|*?midnight2nine,s,1)
exten => s,3,GotoIfTime(20:00-23:59|mon-fri|*|*?eight2midnight,s,1)

> 3. ring phone 1 saturday and sunday all day

exten => s,4,GotoIfTime(*|sat-sun|*|*?weekends,s,1)

That is the decision logic for those three rules.  Now you have to define the 
four contexts, which I've called "nine2eight," "midnight2nine," and 
"eight2midnight."  These contexts will dial the lines as you specify.

Example:

[nine2eight]
exten => s,1,Dial(PHONE1&PHONE2&PHONE3,15,t)
exten => s,2,Dial(PHONE1&PHONE2&PHONE3&PHONE4&PHONE5,,t)

Since midnight2nine and eight2midnight contexts are the same, don't repeat 
your logic -- Put the actual steps in midnight2nine and make your 
eight2midnight context like this:

[eight2midnight]
exten => s,1,Goto(midnight2nine,s,1)

That way if you change what you want to do for that step you don' thave to 
change it in two places.

Of course, I think that you might be better off naming these contexts for some 
*function* rather than the times, but I don't know what the functions 
are.  :-)

> I do not need a in detail answer for each of the three cases... I hope I
> am smart enough to generalise the answer... I just don't see an easy way
> to do this right now.

Hopefully this gets you started.  As I said you've done an excellent job of 
describing what you want in small enough blocks to almost directly convert 
them to Asterisk dialplan logic steps. 

-A.



More information about the asterisk-users mailing list