Proper use of extensions_custom.conf

We’re using FreePBX/Asterisk in a call center environment and have setup the extensions_custom.conf so that instead of using many static inbound routes for our 1000+ DID’s, we’re doing a database lookup with MSSQL and sending the calls to specific Queues depending on the DID configuration in our call center app’s database.

So the extensions_custom.conf is written to first apply some special logic to all inbound trunk calls (whether they have a static inbound route or will be routed dynamicall) with:

exten => _X.,1,Set(__FROM_DID=${EXTEN})
;exten => _X.,n,Set(__INBOUNDCALL=TRUE)
exten => _X.,n,Set(CDR(accountcode)=${EXTEN})
exten => _X.,n,ExecIf($[${LEN(${EXTEN})}>9],Gosub,app-prep-vars|s|1)
exten => _X.,n,ExecIf($[${LEN(${EXTEN})}>9],Gosub,app-check-loop|s|1)
exten => _X.,n,Set(__CALLINGCHANNEL=${CHANNEL})

exten => _X.,n,Noop(No Asterisk Route - Lookup DID Dynamically)

We also have some other custom contexts in the file to field actions from the AMI based redirect/originate commands in the call center app used to place callers on hold, make calls, conference calls, etc.

The weird thing is that this all works. But if I uncomment the 2nd line in from-pstn-custom then bizarre things start happening. With that line uncommented, two of the static routes stop working (not matched/found) but others continue to work fine. I can run a show dialplan on those routes and the dialplan indicates that the routes would be found.

But it’s not just that line. If I put more than 3 lines that are executed (not the Gosub’s) in that from-pstn-custom context then either the db lookups quit working or static routes stop working or we have some other odd behavior related to the dialplan. If I move the other contexts around in the file, similar things happen.

Is this normal or is there something wrong here? :slight_smile:

BTW, we’re on Asterisk 1.25.1 and FreePBX on CentOS 5.3. We have less than 50 extensions, about 10 queues, a dozen static routes, and a couple IVR’s.