Remove prefix for source-based routing

I’m using two asterisk instances in tandem for this purpose as there is an end PBX that connects to endpoints and does the PBX functions that customers use (feature codes, voicemail etc.) and one “core” instance as an intermediary to the CTS provider (through Cisco CUBE devices) that is used to aggregate calls from other customers who use trunking and their own PBX instances as well as the main PBX.

I’m trying to set this up in a way that calls with prefix 1111 sent by the end PBX are sent by the “core” without the prefix to a different CTS provider.

I can currently send calls with a valid number to the second CTS service as shown here:

exten => _0[4]XXXXXXXX,1,NoOp(Call sent out to CTS1)
exten => _0[4]XXXXXXXX,2,Set(CDR(diallingnumber)=${CALLERID(NUM)})
exten => _0[4]XXXXXXXX,3,Set(CDR(diallednumber)=${CALLERID(DNID)})
exten => _0[4]XXXXXXXX,4,Dial(SIP/${CALLERID(DNID)}@CUBE1)
exten => _0[4]XXXXXXXX,5,Goto(s-${DIALSTATUS},1)


exten => _0[8]XXXXXXXX,1,NoOp(Call sent out to CTS2)
exten => _0[8]XXXXXXXX,2,Set(CDR(diallingnumber)=${CALLERID(NUM)})
exten => _0[8]XXXXXXXX,3,Set(CDR(diallednumber)=${CALLERID(DNID)})
exten => _0[8]XXXXXXXX,4,Dial(SIP/${CALLERID(DNID)}@CUBE2)
exten => _0[8]XXXXXXXX,5,Goto(s-${DIALSTATUS},1)

Rather than sending all calls to 04XXXXXXXX via CTS1, what I want to do is dial 111104XXXXXXXX and have the “core” send 04XXXXXXXX calls via CTS2.

exten => _11110[4]XXXXXXXX,1,NoOp(Call sent out to CTS2)
exten => _11110[4]XXXXXXXX,2,Set(CDR(diallingnumber)=${CALLERID(NUM)})
exten => _11110[4]XXXXXXXX,3,Set(CDR(diallednumber)=${CALLERID(DNID:4)})
exten => _11110[4]XXXXXXXX,4,Dial(SIP/${CALLERID(DNID:4)}@CUBE2)
exten => _11110[4]XXXXXXXX.,5,Goto(s-${DIALSTATUS},1)

What ends up happening is that the “core” calls 111104XXXXXXX@CUBE2 rather than 04XXXXXXX@CUBE2

Could anyone provide some guidance on how this should be fixed?

First fix is to mark this up correctly for the forum, by indicating that it is pre-formatted text (</>).

Second likely fix is to understand the use of square brackets in patterns. “[4]” means the same as a simple “4”. I guess that wasn’t the intention, but can’t be certain of the real intention.

A third fix is to put the the sub-string modifier outside the parameter list parentheses.

A probable fourth fix is to add code to set CALLERID(dnid), as this is not normally set (why aren’t you using ${EXTEN}?).

How about to use ${EXTEN:4}??

exten => _11110[4]XXXXXXXX,1,NoOp(Call sent out to CTS2)
exten => _11110[4]XXXXXXXX,4,Dial(SIP/${EXTEN:4}@CUBE2)
exten => _11110[4]XXXXXXXX.,5,Goto(s-${DIALSTATUS},1)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.