TUTORIAL CNAM Lookup for Outbound Calls

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
lgaetz: Don't give up on the FreePBX module. It's a good idea. Just use the hook instead of the cleaver.

21174404.jpg
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
So here's the final one-click installer for Outbound CallerID Name (CNAM) support in both the CDRs and on supported SIP phones.

Clean out existing "experiments" in /etc/asterisk/extensions_override_freepbx.conf and in extensions_custom.conf before you begin.

Prerequisites: PIAF-Green with Asterisk 11 and FreePBX 2.11 or Incredible PBX 11. CallerID Superfecta must already be working with at least the Default option.

Incredible PBX for Raspberry Pi: Edit install-dialout-cnam.sh after download and change PASSWD to raspberry before using installer.

Updates: Once this version is installed, it can be updated and/or CID Superfecta can be reconfigured at any time by simply running the installer again.

Configuration: Everything is preconfigured in FreePBX including extension 701 to support CNAM display for outbound calls. Additional extensions can be configured using FreePBX GUI. Simply turn on the sendrpid option for each extension. Two sendrpid settings are available. Different phones require different ones. Try the first one. Make a test outbound call. When the party answers, if the CNAM is displayed on the phone, then you're done. Otherwise, rinse and repeat with the other sendrpid setting. If it still doesn't work, then your phone doesn't support outbound CNAM display. With Digium phones, don't bother trying.

Code:
cd /root
wget http://incrediblepbx.com/install-dialout-cnam.sh
chmod +x install-dialout-cnam.sh
./install-dialout-cnam.sh

To install with OpenCNAM as the default instead of CallerID Superfecta, use:
Code:
./install-dialout-cnam.sh opencnam
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
What do you mean with number of desired CallerID Superfecta Lookup Scheme?
I have 3 lookup schemes that are to be checked

Here is my output:

Otherwise, press Enter to proceed at your own risk...
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Available CallerID Superfecta Lookup Schemes:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter number of desired CallerID Superfecta Lookup Scheme for Outbound Calls: 2
./install-dialout-cnam.sh: line 68: [: 2: unary operator expected
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Installing...
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Successfully reloaded
--2013-09-15 17:29:29-- http://incrediblepbx.com/dialout-cnam.txt
Resolving incrediblepbx.com (incrediblepbx.com)... 74.86.213.25
Connecting to incrediblepbx.com (incrediblepbx.com)|74.86.213.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1076 (1.1K) [text/plain]
Saving to: `dialout-cnam.txt'

100%[================================================================================================================================================>] 1,076 --.-K/s in 0s

2013-09-15 17:29:30 (13.7 MB/s) - `dialout-cnam.txt' saved [1076/1076]

Dialplan reloaded.
All done.
root@incrediblepbx:~#
Sendrpid of Ext 701 still says No
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Did you read the installer prompt before proceeding? This has only been tested with PBX in a Flash. You're not a candidate if you're using a Raspberry Pi.

With Raspberry Pi, you at least have to change the MySQL password in the script to raspberry. You can only use one CallerID Superfecta template for outbound call CNAM lookups. Each template can have multiple lookup sources. No guarantees it will work even then.

No harm in running the installer again... after you fix the password.
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
Oops, sorry. An empty line may help catch attention to the key message there. :oops:

But after setting password (just once), I get this:
Otherwise, press Enter to proceed at your own risk...
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Available CallerID Superfecta Lookup Schemes:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter number of desired CallerID Superfecta Lookup Scheme for Outbound Calls: ^C
root@incrediblepbx:~#
Code:
#!/bin/bash
PASSWD="raspberry"
VERSION="1.2.1"
..
echo "If you do not agree with these terms and conditions of use, press Ctrl-C now."
echo " "
read -p "Otherwise, press Enter to proceed at your own risk..."
clear
scheme=0
NUMCHOICES=`mysql -uroot -ppassw0rd asterisk -B --skip-column-names -e "SELECT count(source) FROM superfectaconfig where field='order'"`
while [ $scheme -eq 0 ]
do
clear
echo "Available CallerID Superfecta Lookup Schemes:"
mysql -uroot -ppassw0rd asterisk --skip-column-names -e "SELECT value,source FROM superfectaconfig where field='order'"
echo -n "Enter number of desired CallerID Superfecta Lookup Scheme for Outbound Calls: "
read scheme
if [[ $scheme =~ ^[0-9]+$ ]]; then
if [ $scheme -gt $NUMCHOICES ]
then
  scheme=0
  continue
fi
else
scheme=0
continue
fi
done
clear
#echo $scheme
MYSCHEME=`mysql -uroot -ppassw0rd asterisk -B --skip-column-names -e "SELECT source FROM superfectaconfig where field='order' and value=$scheme"`
#echo $MYSCHEME
CIDSFSCHEME=`php -r "echo base64_encode('$MYSCHEME');"`
#echo $CIDSFSCHEME
echo "Installing..."
mysql -uroot -p$PASSWD asterisk -e "update sip set data='yes' where id='701' and keyword='sendrpid'"
mysql -uroot -p$PASSWD asterisk -e "update freepbx_settings set value='0' where keyword='OUTBOUND_CID_UPDATE'"
mysql -uroot -p$PASSWD asterisk -e "update freepbx_settings set value='0' where keyword='OUTBOUND_DIAL_UPDATE'"
/var/lib/asterisk/bin/module_admin reload
cd /tmp
wget http://incrediblepbx.com/dialout-cnam.txt
sed -i '\:// BEGIN Outbound CNAM Support:,\:// END Outbound CNAM Support:d' /etc/asterisk/extensions_custom.conf
sed -i 's|YmFzZV9EZWZhdWx0|'$CIDSFSCHEME'|' /tmp/dialout-cnam.txt
cat /tmp/dialout-cnam.txt >> /etc/asterisk/extensions_custom.conf
rm dialout-cnam.txt
asterisk -rx "dialplan reload"
echo "All done."
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Delete install-dialout-cnam.sh from /root and download the updated 1.2.2 script. There was an overlooked passw0rd still hanging out in the 1.2.1 script.
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
same problem, I see two times more: -ppassw0rd

Available CallerID Superfecta Lookup Schemes:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter number of desired CallerID Superfecta Lookup Scheme for Outbound Calls: ^C
root@incrediblepbx:~#
Code:
PASSWD="raspberry"
VERSION="1.2.2"
..
read -p "Otherwise, press Enter to proceed at your own risk..."
clear
scheme=0
NUMCHOICES=`mysql -uroot -ppassw0rd asterisk -B --skip-column-names -e "SELECT count(source) FROM superfectaconfig where field='order'"`
while [ $scheme -eq 0 ]
do
clear
echo "Available CallerID Superfecta Lookup Schemes:"
mysql -uroot -ppassw0rd asterisk --skip-column-names -e "SELECT value,source FROM superfectaconfig where field='order'"
echo -n "Enter number of desired CallerID Superfecta Lookup Scheme for Outbound Calls: "
read scheme
if [[ $scheme =~ ^[0-9]+$ ]]; then
if [ $scheme -gt $NUMCHOICES ]
then
  scheme=0
  continue
fi
else
scheme=0
continue
fi
done
clear
#echo $scheme
MYSCHEME=`mysql -uroot -p$PASSWD asterisk -B --skip-column-names -e "SELECT source FROM superfectaconfig where field='order' and value=$scheme"`
#echo $MYSCHEME
CIDSFSCHEME=`php -r "echo base64_encode('$MYSCHEME');"`
#echo $CIDSFSCHEME
echo "Installing..."
mysql -uroot -p$PASSWD asterisk -e "update sip set data='yes' where id='701' and keyword='sendrpid'"
mysql -uroot -p$PASSWD asterisk -e "update freepbx_settings set value='0' where keyword='OUTBOUND_CID_UPDATE'"
mysql -uroot -p$PASSWD asterisk -e "update freepbx_settings set value='0' where keyword='OUTBOUND_DIAL_UPDATE'"
/var/lib/asterisk/bin/module_admin reload
cd /tmp
wget http://incrediblepbx.com/dialout-cnam.txt
sed -i '\:// BEGIN Outbound CNAM Support:,\:// END Outbound CNAM Support:d' /etc/asterisk/extensions_custom.conf
sed -i 's|YmFzZV9EZWZhdWx0|'$CIDSFSCHEME'|' /tmp/dialout-cnam.txt
cat /tmp/dialout-cnam.txt >> /etc/asterisk/extensions_custom.conf
rm dialout-cnam.txt
asterisk -rx "dialplan reload"
echo "All done."
 

kenn10

Well-Known Member
Joined
Dec 16, 2007
Messages
3,764
Reaction score
2,173
Has anyone else tried this? When I use it, it changes my outbound caller-id to what the Superfecta lookup is. So if you call 678-234-5678, it changes your outbound caller-id to 678-234-5678. It does do a lookup of the destination and displays it on my Aastra 9143i phone as it should. What am I doing wrong?
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
Did you set sendrpid for the extension from which you make the call in Freepbx?
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Has anyone else tried this? When I use it, it changes my outbound caller-id to what the Superfecta lookup is. So if you call 678-234-5678, it changes your outbound caller-id to 678-234-5678. It does do a lookup of the destination and displays it on my Aastra 9143i phone as it should. What am I doing wrong?


Sorry about that. We tested with a Google Voice number that didn't allow spoofing of the CallerID number so the bug didn't appear. Just reinstall and it should be fixed.
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
Working great, no errors.

However, I still need to edit this to get my lookup to work.
Don't you agree that this makes the script too much US local?
Imho, the rules in Superfecta should work this out, not the script.

Code:
exten => s,n,Set(num2find=${DIAL_NUMBER:-10})
change to 
exten => s,n,Set(num2find=${DIAL_NUMBER})
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
I love that all of the code is now in a single context and override is not req'd, but your script may yet benefit from some tweaks:
  • CALLERID(num) should be CALLERID(number) *edit* scratch this one, they both work
  • review my notes from this post, I think you should be backing up both CALLERID(name) and CALLERID(number) and restoring them before your macro finishes.
  • Reconsider the line that truncates the looked up number to 10 digits, it is very north america centric and doesn't do anything that the Superfecta CID rules can't do anyway (and Rrrr confirmed seconds prior to me posting this, IIRC he is in The Netherlands)
  • You might want to give users the option to choose 'ALL' Superfecta schemes corresponding to an encoded value of "QUxMfEFMTA==" (without quotes)

2 down. 1 to go. Ver. 1.2.7 is ready to go. I originally didn't restore the CALLERID(name) because all of the "phone companies" throw it in the bit bucket anyway, but probably good idea anyway. #3 was really to support AsteriDex so I've moved it. Otherwise, AsteriDex code would take some non-Americanization.
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
Ver. 1.2.6 working great.
Just one more adjustment while you are adding ALL schemes for Superfecta: to remove ":-10" in case of Asteridex lookup:
Code:
; Use the 4 lines below for AsteriDex only lookups
;exten => s,n,Set(num2find=${DIAL_NUMBER:-10})

@Igaetz: anything (except changing hardware) to improve execute speed of Superfecta?
On a Raspberry Pi it is noticable for incoming and outgoing CNAM lookup: it really seems to take a long time (6000 entries in db).
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Ver. 1.2.6 working great.
Just one more adjustment while you are adding ALL schemes for Superfecta: to remove ":-10" in case of Asteridex lookup:
Code:
; Use the 4 lines below for AsteriDex only lookups
;exten => s,n,Set(num2find=${DIAL_NUMBER:-10})

Just don't uncomment that line if you don't want NANPA-only AsteriDex lookups. :idea:
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
I should have mentioned, but I think it is necessary unset the var CALLERID(name) before calling the superfecta AGI. If the user has the trunk provided lookup source configured, it will use that string and retrun the wrong info.


Fixed in 1.2.8. Thanks.
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
If you are using the built in Asteridex module for Superfecta, it may be slow because it is doing a search by regular expression (regex). If the numbers in your Asteridex are very clean (i.e. no non-digits, or extension numbers etc) then you could do a simple SELECT ... LIKE search using the generic Database module, I suspect that would speed things up a lot.


Thanks, I am using just one scheme and its set to Database module only, using SELECT `name` FROM `user1` WHERE `out`= :thenumber . Table user1 has only 150 contacts.

Is there a way I can enter a timer to measure?
 

Members online

No members online now.

Forum statistics

Threads
25,779
Messages
167,505
Members
19,199
Latest member
leocipriano
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