Need to edit dialed number before it is dialed

I have a strange problem. We have a Nortel system that uses a SIP trunk to our Asterisk hub, which then provides access to our global VOIP network. Due to a limitation of the Nortel system, they are passing both the location prefix and the number to dial over the SIP trunk. (For example, you dial “500” to get to the hub, then can dial an internal extension, or another prefix to hit our global network from our universal dial plan.)

So, if a user on Nortel dials 500-1000, they are calling extension 1000 off our hub. Nortel delivers the number dialed as “500-1000.” I need a simple way to strip off the 500 on this incoming call, then let all the routing of the hub take over. (Dialing 500-530-1000 would dial extension 1000 in our Brasil office, but the hub needs to receive 530-1000.)

I wrote a simple script to strip off the 500 then use the Dial command with the rest of the digits, and that works for extensions local to the hub server, but fails when calling “SIP/5301000” as it is assuming that is a local extension.) Is there some way I can strip off the first three digits, then redial the left-over number as if it had simply originated from a local extension?

Thank you,

If I understood you correctly, doing this in your trunk Dial Rules will allow a user to dial 5001234 and only have the 1234 passed:


For calls originating on the Asterisk box, that work. This call originates on the Nortel system. The end user dials 500-1234. The 500 tells Nortel to route this to the SIP trunk that goes to Asterisk, but Nortel is unable to remove the 500. When that call hits the Asterisk system, I want to remove the 500 before any other processing, so all inward routing, feature access, etc. will work.

Make sense?

see here

Work, but when I try to upload the module it says it needs to be tar+gzip format. I searched for a quick tutorial on how to install modules manually, but didn’t find one. Can you point me in the right direction?

Thanks again,

lets keep this all in one tread

I tried this module, but it’s not quite what I need. Basically the instant a call hits my Asterisk server, before any routing or other processing occurs, I need to remove the first three digits from the dialed num, if it came from the trunk in question. I scripted a custom destination that does what it needs to do, but it happens to late, and superceeds “normal” call processing like voice mail, other routes, etc.

Any other ideas out there?


Im not sure what your difficulty is: have an inboud route with 5001234 pointing to setcid, and then just route it where ever you need the call to go?

The problem is that I can’t explicit route the call to one destination. If they dial 500100 is should inwardly dial 1000, 5001001 dial 1001, etc. While I could build a CID change for every extension, that would become very difficult to maintain, as I would have to create a CID change for every extension, service, feature, etc.

What I really need is for the trunk to know that 500 should be stripped before delivering the call to the ast call router… Sort of like what is does on an outbound call, except on an inbound call before anything gets processed.

yup - your right. I doubt there is anything other than a custom context that can handle what you need (unless you want to use outbound routes… which is kinda backwards)

Send your incoming calls from your Nortel to a Custom Context that does the following:

Set variable that is the dialed number with the first three digits stripped.
Goto context = from-internal, extension = variable you just set, priority = 1

So, the above really helped out. I had to do a couple things to make everything work. I added a custom destination, and routed _500. to it. That custom destination is:

exten => _5XX9.,1,Dial(Zap/g0/${EXTEN:4}, 20)
exten => _5XX9.,n,Hangup

exten => _500XXXX,1,Goto(from-internal,${EXTEN:3},1)
exten => _500XXXX,n,Hangup

exten => _500.,1,NoOp(Redialing ${EXTEN})
exten => _500.,n,Goto(outbound-allroutes,${EXTEN:3},1)

As I’m no expert on dialplan, is there anything in this I have missed?