Alter incoming CallerID - Dahdi Channels

Would anyone know how to prepend “9” to incoming calls from the DAHDI channels? For for example on the phone system we have it setup so they have to dial “9” to get an outside line, but when calls come up in the history on the phone there is no 9 so they can not press to quick dial it.

I have tried to modify the caller id by using these document, but I have only been able to get it to work on SIP trunks, and not DAHDI. This document seems to be really outdated so I am wondering if it no longer applies for Dahdi channels.

Are these Polycom phones?

Yes. Polycom SoundPoint IP 331

I assume you want to do this so the redial key works?

You need to run version 3.2 or later software. You can define a dial plan just for directory and redial options to prepend the 9.

If you want to go down this path I can send you an example dial string.

Yes. For example, on the Polycom phones, they should be able to select the down arrow for “Missed Calls”, select a call, and then press the “dial” soft key to dial that number. The same thing for softphones like Bria. Currently when you go to those calls they do not have a “9” in front.

So basically, on the Dahdi channel, we just want to change the callerid on any incoming call to prepend a “9”.

The Polycom’s on version 3.2 and later have a discrete dial plan for the directories that you can program to add the 9. Much more elegant. Especially if you integrate LDAP to an Exchange server.

This sounds like a great solution, but the only thing is with this client, they have a lot of remote workers that will be using different softphones. So I think it would make more sense to somehow try and modify the asterisk dialplan to prepend the 9 to incoming calls?

With other clients I have used Switchvox from digium, and it essentially has a feature which you can alter the callerid on the inbound dialplan easily to prepend this 9. It has worked really well. So I thought there might be a way to modify freepbx to do this as well…

Anyone know how to do this with the freepbx dial plans?

Hi SkykingOH,

I was wondering if you could point me in the direction of where to edit the directory settings for the Polycom phones so I can prepend 9 just for the directory features on the phone.

After playing around with Bria3 and Outlook I am now seeing why you recommend adjusting the phones directly and not adjusting the dialplan within asterisk.

Hi SkykingOH. I actually just found your instructions here…

I have this working. The one thing I am wondering, is if you can use the freepbx interface to set these settings. I just don’t want an update, or someone accidentally re-save the template which will overwrite these settings.

No, that is what the template editor is for in Endpoint Manager. You can also create a custom template.

I wish some users would step up and help groom posts like this into a decent searchable wiki.

Well, this script simply slams a 9 in front of your numbers. It’s messy, makes the CDR’s wrong and is not elegant (sorry stonet).

If you are lucky enough to have Polycom phones that support this feature, not programming it correctly is just letting down your users (and the people that paid for the phones).

I have used a different approach by using a snipit of custom dial plan to add the 9 to the CID received on a trunk by putting:


exten => _X.,1,Set(CALLERID(number)=9${CALLERID(number))
exten => _X.,n,Goto(from-analog,${EXTEN},1)

;End of [from-prepend-nine]

in /etc/asterisk/extensions_custom.conf, then all that should be needed is to replace context=from-analog with context=from-prepend-nine in /etc/asterisk/chan_dahdi.conf.

I have used this with SIP trunks but can’t think of a reason why it won’t work with dahdi trunks.

Maybe this is debatable? hahaha. I know with the Switchvox system from Digium, they seem to recommend prepending 9 to the dial plan. I can’t find the documentation on it, but I remember it was on their website at one point.

Also, I just logged into a switchvox phone system, and I see a spot to modify the Polycom Digitmap, but I don’t see a spot to modify the “dialplan.applyToDirectoryDial” variable.

Just comparing switchvox to freepbx for interest…

If you have Polycoms fine, the phone route is more elegant but with a mixture of phones the sledgehammer approach is the easy way out.

One other thing to consider might be to modify outgoing route selection so the 9 is not required. That is the approach I have ended up with, I don’t use any access codes for my trunks which include US and UK sip, two mobile GSM providers through Portech gateways and dahdi telco, asterisk just works out what to do with the calls from the digits dialed and the outbound route setup.

Whatever you do CID’s can appear in a variety of flavours, for example one of my GSM providers sends CID as NXXNXXXXXX and the other as +1NXXNXXXXXX, so I use a similar snipit of dialplan to check for this and strip off the +1. On UK trunks CID’s come in as 0 plus the number so I strip off the zero and replace it with 01144 (we use the north american dialling methods). Nothing is foolproof so there are exceptions but it works most of the time.