Use CNAM from provider unless number is in Asteridex

richie

Member
Joined
Nov 27, 2007
Messages
34
Reaction score
0
Callcentric recently started providing free incoming CNAM on their DIDs, so I'm looking for advice on the best way to do the following:

When a call is received check to see if the calling number is in the local asteridex database and if it is replace the CNAM from the provider with the name from asteridex.

If the calling number is not in asteridex, just use the CNAM from the provider.

I'm thinking I'd probably need a variation of this post:
http://pbxinaflash.com/community/th...routines-only-if-not-filled-by-provider.1775/
 
Last edited by a moderator:

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,207
Reaction score
5,236
If you install the CallerID Superfecta and only activate the AsteriDex option, it should do what you're looking for.
 

jeffmac

Guru
Joined
Jan 16, 2008
Messages
230
Reaction score
9
Unfortunately, I just ran a test and it doesn't work that way, Ward. If you look at the callerid.php code, if all of the selected lookups fail, the last lines of code are:

$value=$thenumber;
echo $value;
exit ;

So if theres a "not found" condition in ALL selected lookups you get the cnam set to the number (without regard to what it was before the call, meaningful or not).

The worse problem lies in the Freepbx code, because the call to the Superfecta simply sets the callerid name to whatever comes back from the call (to the Superfecta). If we changed the Superfecta to return a "null" value if all lookups fail, then the name would still be replaced - with a null!

My complaint was that frequently the lookups (other than Asteridex, of course) have very generic descriptions. "Land Line NE", or "Cell Phone Arkansas" are not meaningful overrides of many provider supplied names. That's why I coded the override I did. Now if the provider sends a generic cnam my code still bypasses the lookup, which MIGHT find a better match. But that gets into the issue that Ward mentioned about having to check for what variaions of useless cnam are sent My code is already checking for 4 possibilities I've received - you can't check every possibility that might be sent.

The code I posted is still working and easy to implement, simply copy it to a extensions_override_freepbx.conf file in the /etc/asterisk directory and restart asterisk ie: amportal restart. The only downside is that if Freepbx changes that code in some release I'll have to chase it down and update my override (and if you use it you could have problems if you update to that future FREEPBX and I haven't updated yet).

I'm still learning this stuff (including PHP) but I can usually follow the code flow, having been in programming and the IT business for over 30 years. I still have couple things to learn, though, because I've been trying to modify the Superfecta to circumvent this issue - but, like I said, PHP is new to me. Success has eluded me so far.

Jeff
 

tel0p

Guru
Joined
Nov 20, 2007
Messages
195
Reaction score
0
The code I posted is still working and easy to implement, simply copy it to a extensions_override_freepbx.conf file in the /etc/asterisk directory and restart asterisk

@Jeff: where is this code posted?

I was just thinking of tackling the same issue as I've recently installed a box with an ATA and the Qwest provided CNAM is lacking, at best. I'd _much_ rather provide asteridex/internet provifed info _if_ the POTS data is generic enough (aka matches 'CELLULAR CALLER' , etc).

Cheers.
 

jeffmac

Guru
Joined
Jan 16, 2008
Messages
230
Reaction score
9
Well, as someone else said (Tshif, maybe?) sometimes when someone asks a question it prompts you to finish something you had put on the shelf. So this thread has prompted me to do more. I did not have modify any PHP code - so Ward's Superfecta is still intact (I know its getting more improvements in another thread).

What I did was change my "override" of the Freepbx call to the Superfecta. This code is in a context named "cidlookup".

The new function is exactly what richie requested. If the Superfecta is installed with ONLY Asteridex configured, then if Asteridex does not find a number in its database, the original incoming callerid name will be restored. To accomplish this I simply saved the callerid name before calling the Superfecta. When the Superfecta returns, if the callerid name = callerid number, then I reset the callerid name from the saved name. Here is the necessary code:

[cidlookup]
include => cidlookup-custom
exten => cidlookup_1,1,Set(SaveCNAM=${CALLERID(name)})
exten => cidlookup_1,n,Set(CALLERID(name)=${CURL(http://localhost:80/callerid.php?thenumber=${CALLERID(num)})})
exten => cidlookup_1,n,GotoIf($[ "${CALLERID(name)}" = "${CALLERID(num)}" ] ?:noneed)
exten => cidlookup_1,n,Set(CALLERID(name)=${SaveCNAM})
exten => cidlookup_1,n,NoOp(${CALLERID(name)})
exten => cidlookup_1,n(noneed),Return()
exten => cidlookup_return,1,LookupCIDName
exten => cidlookup_return,n,Return()

Assumptions:
1. You have installed the Callerid Superfecta (Nerdvittles, or the newer module shouldn't matter as they work the same)
2. You have customized the appropriate inbound routes with a Callerid Source => Superfecta
3. You haven't customized any OTHER callerid source in Freepbx (this is because I suspect this would create multiple entries in the cidlookup context, and I haven't dones this or tested it - and this code OVERRIDES the cidlookup context created by Freepbx)
4. Copy this code into a file named extensions_override_freepbx.conf in the /etc/asterisk subdirectory.
5. restart asterisk by entering "amportal restart" at the command prompt while logged on to your PIAF system

Doing this via "override" means I have to re-validate it every time Freepbx updates, so just beware - this is something you might want to check any time you update Freepbx code levels.

richie, I hope you choose to give this a try. its not too scary and appears to be working well for me.

Jeff
 

richie

Member
Joined
Nov 27, 2007
Messages
34
Reaction score
0
Thanks a lot Jeff! I will definitely give your dial plan a try. Actually, I was already playing with what you had in the original thread, but something hot came up at work and I just had the time to get back to this thread tonight. Thanks again, -Richie
 

Members online

Forum statistics

Threads
25,837
Messages
167,905
Members
19,259
Latest member
dancosge
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top