[from-trunk] ; just an alias since VoIP shouldn't be called PSTN include => from-pstn [from-pstn] include => from-pstn-custom ; create this context in extensions_custom.conf to include customizations include => ext-did include => from-pstn-timecheck ; this has to be included otherwise it overrides ext-did [from-pstn-timecheck] exten => .,1,Goto(s,1) ; catch-all matching for calls that have DID info (if a DID route hasn't matched them) exten => s,1,GotoIf($[${IN_OVERRIDE} = forcereghours]?from-pstn-reghours,s,1:) exten => s,2,GotoIf($[${IN_OVERRIDE} = forceafthours]?from-pstn-afthours,s,1:) exten => s,3,GotoIfTime(${REGTIME}|${REGDAYS}|*|*?from-pstn-reghours,s,1:) exten => s,4,Goto(from-pstn-afthours,s,1) [from-pstn-reghours] exten => s,1,GotoIf($[${FAX_RX} = disabled]?from-pstn-reghours-nofax,s,1:2) ; if fax detection is disabled, then jump to from-pstn-nofax - else continue exten => s,2,Answer exten => s,3,Wait(1) exten => s,4,SetVar(intype=${INCOMING}) exten => s,5,Cut(intype=intype,-,1) exten => s,6,GotoIf($[${intype} = EXT]?7:9) ; If INCOMING starts with EXT, then assume its an extension exten => s,7,Wait(3) ;wait 3 more second to make sure this isn't a fax before dialing someone exten => s,8,Goto(ext-local,${INCOMING:4},1) exten => s,9,GotoIf($[${intype} = GRP]?10:12) ; If INCOMING starts with GRP, then assume its a ring group exten => s,10,Wait(3) exten => s,11,Goto(ext-group,${INCOMING:4},1) exten => s,12,GotoIf($[${intype} = QUE]?13:15) exten => s,13,Wait(3) exten => s,14,Goto(ext-queues,${INCOMING:4},1) exten => s,15,Goto(${INCOMING},s,1) ; not EXT or GR1 - it's an auto attendant exten => fax,1,Goto(ext-fax,in_fax,1) exten => h,1,Hangup [from-pstn-reghours-nofax] exten => s,1,SetVar(intype=${INCOMING}) exten => s,2,Cut(intype=intype,-,1) exten => s,3,GotoIf($[${intype} = EXT]?4:5) ; If INCOMING starts with EXT, then assume its an extension exten => s,4,Goto(ext-local,${INCOMING:4},1) exten => s,5,GotoIf($[${intype} = GRP]?6:7) ; If INCOMING starts with GRP, then assume its a ring group exten => s,6,Goto(ext-group,${INCOMING:4},1) exten => s,7,GotoIf($[${intype} = QUE]?8:11) ;queue exten => s,8,Answer ; answer call before queue exten => s,9,Wait(1) exten => s,10,Goto(ext-queues,${INCOMING:4},1) exten => s,11,Answer ; answer call before auto attendant exten => s,12,Wait(1) exten => s,13,Goto(${INCOMING},s,1) ; not EXT or GR1 - it's an auto attendant exten => fax,1,Goto(ext-fax,in_fax,1) exten => h,1,Hangup [from-pstn-afthours] exten => s,1,GotoIf($[${FAX_RX} = disabled]?from-pstn-afthours-nofax,s,1:2) ; if fax detection is disabled, then jump to from-pstn-nofax - else continue exten => s,2,Answer exten => s,3,Wait(1) exten => s,4,SetVar(intype=${AFTER_INCOMING}) exten => s,5,Cut(intype=intype,-,1) exten => s,6,GotoIf($[${intype} = EXT]?7:9) ; If INCOMING starts with EXT, then assume its an extension exten => s,7,Wait(3) ;wait 3 more second to make sure this isn't a fax before dialing someone exten => s,8,Goto(ext-local,${AFTER_INCOMING:4},1) exten => s,9,GotoIf($[${intype} = GRP]?10:12) ; If INCOMING starts with GRP, then assume its a ring group exten => s,10,Wait(3) exten => s,11,Goto(ext-group,${AFTER_INCOMING:4},1) exten => s,12,GotoIf($[${intype} = QUE]?13:15) exten => s,13,Wait(3) exten => s,14,Goto(ext-queues,${AFTER_INCOMING:4},1) exten => s,15,Goto(${AFTER_INCOMING},s,1) ; not EXT or GR1 - it's an auto attendant exten => fax,1,Goto(ext-fax,in_fax,1) exten => h,1,Hangup [from-pstn-afthours-nofax] exten => s,1,SetVar(intype=${AFTER_INCOMING}) exten => s,2,Cut(intype=intype,-,1) exten => s,3,GotoIf($[${intype} = EXT]?4:5) ; If INCOMING starts with EXT, then assume its an extension exten => s,4,Goto(ext-local,${AFTER_INCOMING:4},1) exten => s,5,GotoIf($[${intype} = GRP]?6:7) ; If INCOMING starts with GRP, then assume its a ring group exten => s,6,Goto(ext-group,${AFTER_INCOMING:4},1) exten => s,7,GotoIf($[${intype} = QUE]?8:11) ;queue exten => s,8,Answer ; answer call before queue exten => s,9,Wait(1) exten => s,10,Goto(ext-queues,${AFTER_INCOMING:4},1) exten => s,11,Answer ; answer call before auto attendant exten => s,12,Wait(1) exten => s,13,Goto(${AFTER_INCOMING},s,1) ; not EXT or GR1 - it's an auto attendant exten => fax,1,Goto(ext-fax,in_fax,1) exten => h,1,Hangup [from-sip-external] include => from-pstn ;give external sip users congestion and hangup exten => _.,1,AbsoluteTimeout(15) exten => _.,2,Congestion exten => _.,3,Hangup