envoy510

The chocolate ration is being increased to 25 grammes per week.

Monthly Archives: August 2012

How to blacklist by caller id name in Asterisk/FreePBX

I use Asterisk (1.8.11-cert5)/FreePBX (2.10.0) for my home phone system.  For years I’ve been pestered by a specific company that is running a credit card rate reduction scam.  I’ve tried and tried to get off their list, to no avail.  I finally got sick of it, so I looked to Asterisk/FreePBX to see if I could blacklist the calls.  The problem is their number changes, but their caller id name does not.  (I’m not going to list it here, since I don’t want them to see this and decide to make their caller id name less regular.)

There’s a file, /etc/asterisk/extensions_override_freepbx.conf, that can be used to override definitions in /etc/asterisk/extensions_additional.conf.  In this latter file is the definition of app-blacklist-check:

[app-blacklist-check]
include => app-blacklist-check-custom
exten => s,1,GotoIf($["${CALLERID(number)}" = "Unknown"]?check-blocked)
exten => s,n,GotoIf($["${CALLERID(number)}" = "Unavailable"]?check-blocked)
exten => s,n,GotoIf($["foo${CALLERID(number)}" = "foo"]?check-blocked:check)
exten => s,n(check-blocked),GotoIf($["${DB(blacklist/blocked)}" = "1"]?blacklisted)
exten => s,n(check),GotoIf($["${BLACKLIST()}"="1"]?blacklisted)
exten => s,n,Set(CALLED_BLACKLIST=1)
exten => s,n,Return()
exten => s,n(blacklisted),Answer
exten => s,n,Wait(1)
exten => s,n,Zapateller()
exten => s,n,Playback(ss-noservice)
exten => s,n,Hangup
;--== end of [app-blacklist-check] ==--;

This is the text we want to copy to /etc/asterisk/extensions_override_freepbx.conf, and make some minor additions:

include => app-blacklist-check-custom
;;;ADDED by me:
exten => s,1,GotoIf($["${CALLERID(name)}" = "FOO INC"]?blacklisted)
exten => s,n,GotoIf($["${CALLERID(name)}" = "WINNER"]?blacklisted)
;;;CHANGE: priority goes from `1' to `n':
exten => s,n,GotoIf($["${CALLERID(number)}" = "Unknown"]?check-blocked)
;;;..END additions
;; the rest should be the same as that in
;; the [app-blacklist-check] section in extensions_additional.conf
...

Lines 3 and 4 are the additions, and the block all calls from when the caller id matches “FOO INC” or “WINNER.”  The latter is an actual caller id that I get from time to time.

It would be nice if the UI in FreePBX allowed me to do this without resorting to editing system files, but it’s not that horrible of a hack.  I just need to make sure that when Asterisk or FreePBX is upgraded that I check the code in the file I copied from to make sure it didn’t change in ways that break my custom code.

EDIT 9/4/2012: the second GotoIf needs to have a priority of “n” not “1”.