Clean up Incoming Caller ID

Hi,

Is it possible to clean up the caller id from an incoming call before passing it to the extensions.

I have a problem with a Panasonic KX-TGP550, most of the time it works fine, but when I receive a phone call from a number formatted ( 0114-123 4567 ) the phone doesn’t respond and in Asterisks logs I get an Internal Server Error message from the phone.

I am giving the massive assumption that this is to do with the Caller ID, I don’t really know how to test it other than waiting for phone calls to arrive with this style of formatted caller id.

Now is it possible to get FreePBX / Asterisk to clean up the callerID so it just becomes 01141234567? Get rid of all spaces and dashs?

Many Thanks
Tim Pearson

I have figured it at last…

I added this to /etc/asterisk/extensions_custom.conf

[from-trunk-sip-OBITRUNK1] exten => _X!,1,AGI(clean-caller-id.php) ;calls script located in /var/lib/asterisk/agi-bin exten => _X!,n,Goto(from-trunk,${EXTEN},1) ;continue with normal inbound handling
*from-truck-sip-OBITRUNK1 is the context set for trunk the calls are coming from.

And created the following file /var/lib/asterisk/agi-bin/clean-caller-id.php, this file removes any spaces and dashs from the caller id.
[php]
#!/usr/bin/php -q

<? set_time_limit(0); require_once "phpagi.php"; require_once "phpagi-asmanager.php"; $agi = new AGI(); $CallerID = $agi->request["agi_callerid"]; $agi->verbose("XXXXXXXXX OLD CallerID : $CallerID "); $CallerID = str_replace(" ", "", $CallerID); $CallerID = str_replace("-", "", $CallerID); $agi->exec('Set',"CALLERID(num)=$CallerID"); $agi->exec('Set',"CALLERID(name)=$CallerID"); $agi->exec('Set',"CALLERID(ani)=$CallerID"); $agi->verbose("XXXXXXXXX NEW CallerID : $CallerID "); exit; ?>

[/php]

Ah ok, thanks, any clue please ?

Then I suggest you read some more. The recipe you followed created a context that modifies your CID . you need to send your inbound calls to that context.

Hey same as problem, a cure !! THANKS !!
(Not tried it yet…)
Dave

Finger trouble, Should of said ‘same as my problem’

Can’t get this to work, any ideas ?

Does any have an idea why this doesn’t work?. I’ve changed the OBITRUNK1 in extensions_custom.conf to reflect my trunk name. (Under Connectivity - Trunks Trunk Name half way down)
The only thing I can think of is maybe this is incorrect and should be different ? Without this working this really makes FreePBX useless, because inbound routes can’t be directed properly and caller ID passed to the phone is messed up with an added ‘20’ instead replacing the added space.

I’m not a PHP expert but can’t really see a problem with the script ?

Dave.

Hi Dave, The PHP didn’t copy in very well above, try this instead:

#!/usr/bin/php -q

<? set_time_limit(0); require_once "phpagi.php"; require_once "phpagi-asmanager.php"; $agi = new AGI(); $CallerID = $agi->request["agi_callerid"]; $agi->verbose("XXXXXXXXX OLD CallerID : $CallerID "); $CallerID = str_replace(" ", "", $CallerID); $CallerID = str_replace("-", "", $CallerID); $agi->exec('Set',"CALLERID(num)=$CallerID"); $agi->exec('Set',"CALLERID(name)=$CallerID"); $agi->exec('Set',"CALLERID(ani)=$CallerID"); $agi->verbose("XXXXXXXXX NEW CallerID : $CallerID "); exit; ?>

Hi Tim, Thanks for that I thought it looked a bit like HTML tags in the code !
I’ll give it a go and report back
Thanks again,
Dave.

Still not working :frowning: The only think thing I changed was the name of the trunk the call came in on in the extensions_custom.conf file. Looking at the log it appears the call came in correctly on trunk SIP/BTLL-00000010 the trunk name is BTLL do I need add the ‘-00000010’ bit to the conf file ?
I put the additional lines at the start of the extensions_custom.conf file before a few of lines for my UKDDI lines other than that it’s empty

Any ideas please.
Dave.

I’ve looked into this some more and obviously I don’t need to add the ‘-00000010’ as mentioned before. I still can’t get this to work though…

Any alternative ideas to get around this issue ?
I cant get this to work…

Bump

Do you even see the messages in your asterisk log? You aren’t giving us much to go on here.

Yes, numbers show up but they still include the - and a space (0114-123 4567) so I assume the patch is not working for some reason. I think the extensions_custom.conf gets ‘called’ when a call comes in then runs the script ?

Dave.

You aren’t following. Do you see this: XXXXXXXXX NEW CallerID :

in the asterisk log file.

I’ll post the log as soon as I edit out my number !

Here’s the log http://pastebin.com/CxnnxQEU

Dave

Yet you are using the from-trunk context, did you try the new context you so laboriously built instead?