I've been able to work around Broadvoice and their horrible technical support and engineering.
I've implemented a callerid solution in asterisk using the following:
- Manual Database Entries for Blacklisting
- Google Contact Synchronization
- Opencnam Lookups
Blacklisting
I add political, charity, religious organizations and businesses that I've had dealings with that I never want to talk to again to a blacklist. They don't follow do-not call rules here in the US.
Connect to the asterisk console using asterisk -r
Add the number the database. I add the number with and without the country code because callerid comes in differently
database put blacklist 6305392500 1
database put blacklist 16305392500 1
Google Contact Synchronization
I followed the instructions on the PBX in a Flash Forums below to setup the script.
I modified the python script to take out the plus symbol and also remove the the country code. I planned on using the google contacts for caller id for Google Voice as well as from my voip provider.
# Insert the number into the cidname database, reinsert the country code if defined.
#os.system("/usr/sbin/asterisk -rx \'database put cidname +%s%s \"%s\"\'" % (country_code,phone.text,entry.title.text))
os.system("/usr/sbin/asterisk -rx \'database put cidname %s%s \"%s\"\'" % (country_code,phone.text,entry.title.text))
os.system("/usr/sbin/asterisk -rx \'database put cidname %s \"%s\"\'" % (phone.text,entry.title.text))
Added A Crontab Entry That Runs Every 30 Minutes
0,30 * * * * /usr/local/bin/python /usr/local/bin/googlecontacts.py > /dev/null 2>&1
Opencnam Lookup
Here's the cnam.agi. I made it an executable and added it to /usr/share/asterisk/agi-bin/. Your install may be different. You'll need the curl binary to make it work. I also log the cnam transactions in a temporary log file.
cnam.agi
#!/bin/bash
cidnum=$1
TODAY=$(date)
name=`curl -s -X GET https://api.opencnam.com/v1/phone/$cidnum?format=PBX`
echo $TODAY >> /tmp/cnam.log
echo $cidnum >> /tmp/cnam.log
echo $name >> /tmp/cnam.log
echo "" >> /tmp/cnam.log
if [ -n "$name" ]; then
echo "SET VARIABLE lookupname \"${name}\""
read RESPONSE
exit 0
else
exit 1
fi
Here's everything in the extensions.conf
[from-broadvoice]
exten => _X!,1,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}?blacklisted,s,1)
exten => _X!,n,Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})})
exten => _X!,n,GotoIf($["${CALLERID(name)}" = ""]?blank)
exten => _X!,n,Dial(SIP/holla,30,tr)
exten => _X!,n,Voicemail(holla)
exten => _X!,n,Playback(vm-goodbye)
exten => _X!,n,Hangup()
exten => _X!,n(blank),NoOp(cnam.agi)
exten => _X!,n,AGI(cnam.agi,${CALLERID(num)})
exten => _X!,n,Set(CALLERID(name)=${lookupname})
exten => _X!,n,Dial(SIP/holla)
exten => _X!,n,Voicemail(holla)
exten => _X!,n,Playback(vm-goodbye)
exten => _X!,n,Hangup()
[from-googlevoice]
exten => _X!,1,NoOp(Call from Google Voice)
exten => _X!,n,Set(CALLERID(num)=${CUT(EXTEN,/,2)})
exten => _X!,n,Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})})
exten => _X!,n,GotoIf($["${CALLERID(name)}" = ""]?blank)
exten => _X!,n,Dial(SIP/holla,30,D(:1))
exten => _X!,n,Hangup()
exten => _X!,n(blank),NoOp(cnam.agi)
exten => _X!,n,AGI(cnam.agi,${CALLERID(num):1})
exten => _X!,n,Set(CALLERID(name)=${lookupname})
exten => _X!,n,Dial(SIP/holla,30,D(:1))
exten => _X!,n,Hangup()
[blacklisted]
exten => s,1,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,Wait(1)
exten => s,n,Hangup()
No comments:
Post a Comment