I have a new install (and I am new to Asterisk) of Asterisk 10.6.1 / DAHDI 2.6.1 on a Centos 6.2 box. I cannot get something to work and either I am not understanding it or I cannot seem to figure out how to do this. My system has a PRI and SIP trunks and it connects to three other phone systems via PRI or SIP. There are no phones directly connected to it. Basically right now this is what I have (with the extra stuff removed) and it works:
[from-pstn] ;from the pri
exten => _X.,1,Goto(to-did,${EXTEN},1)
[from-sip] ;from the SIP trunks
exten => _X.,1,Goto(to-did,${SIP_HEADER(TO):5:10},1)
[to-did]
include => no-did-match
exten => 8005551212,1,Goto(to-toshiba,${EXTEN},1)
exten => 8005551213,1,Goto(to-esi,${EXTEN},1)
;..... more numbers
[no-did-match]
exten => _X.,1,Noop(Catch-All DID Match - not found ${EXTEN} - Sending to Default)
exten => _X.,n,Goto(to-zultys,${EXTEN},1)
[to-toshiba]
exten => _X.,1,Dial(${TRUNK_TOSHIBA}/${EXTEN},32,e)
exten => _X.,n,Goto(bad-number,${EXTEN},1)
[to-esi]
exten => _X.,1,Dial(${TRUNK_ESI_PRI}/${EXTEN},32,e)
exten => _X.,n,Goto(bad-number,${EXTEN},1)
[to-zultys]
exten => _X.,1,Dial(${TRUNK_ZULTYS_PRI}/${EXTEN},32,e)
exten => _X.,n,Goto(bad-number,${EXTEN},1)
[from-internal] ; from the other systems for outbound calls
exten => _X.,1,Goto(dial-number,${EXTEN},1)
[dial-number]
exten => _NXXNXXXXXX,1,Goto(dial-TDS,${EXTEN}, 1)
;... more outbound rules and destinations
What I want to do is include the to-did context in the dial-number context so if one of the systems dials a number that exists in another system, it just routes the call internally. Here is how I tried to do it but it does not work:
[from-pstn] ;from the pri
exten => _X.,1,Goto(to-did,${EXTEN},1)
exten => _X.,n,Goto(no-did-match,${EXTEN},1)
[from-sip] ;from the SIP trunks
exten => _X.,1,Goto(to-did,${SIP_HEADER(TO):5:10},1)
exten => _X.,n,Goto(no-did-match,${SIP_HEADER(TO):5:10},1)
[to-did]
exten => 8005551212,1,Goto(to-toshiba,${EXTEN},1)
exten => 8005551213,1,Goto(to-esi,${EXTEN},1)
;..... more numbers
[no-did-match]
exten => _X.,1,Noop(Catch-All DID Match - not found ${EXTEN} - Sending to Default)
exten => _X.,n,Goto(to-zultys,${EXTEN},1)
;....
[from-internal] ; from the other systems for outbound calls
exten => _X.,1,Goto(to-did,${EXTEN},1)
exten => _X.,n,Goto(dial-number,${EXTEN},1)
;....
With that example if the number is not in to-did, it rejects the call in error instead of processing to the next line. I have also tried gosub with the same results. So I read to control sort order use include statements, but it does not work either -
[from-pstn] ;from the pri
include => to-did
include => no-did-match
;.....
[to-did]
exten => 8005551212,1,Goto(to-toshiba,${EXTEN},1)
exten => 8005551213,1,Goto(to-esi,${EXTEN},1)
;..... more numbers
[no-did-match]
exten => _X.,1,Noop(Catch-All DID Match - not found ${EXTEN} - Sending to Default)
exten => _X.,n,Goto(to-zultys,${EXTEN},1)
;.....
[from-internal] ; from the other systems for outbound calls
include => to-did
exten => _X.,1,Goto(dial-number,${EXTEN},1)
;.....
All the calls now just follow the no-did-match destination. If I comment that out and dial one of the listed did numbers it errors out and does not match. I do not understand why, it matches just fine when using a Goto, but by using the include I am not sure how to change the ${EXTEN} for the sip calls to get the number from the SIP header, but right now my priority is getting the pri calls to work. I have tried various combinations is goto, gosub with a gotoif and includes and I cannot get this to work. Anyone have a idea why? Is there a way if you do a goto, and there is not a match, it just continues instead of erroring out and rejecting the call?