envoy510

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

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”.

Advertisements

3 responses to “How to blacklist by caller id name in Asterisk/FreePBX

  1. Igor August 20, 2014 at 8:05 am

    exten => _X!,n,GotoIf(${BLACKLIST()} = 1)?blacklisted:check)
    exten => _X!,n(blacklisted),Zapateller()
    exten => _X!,n,Hangup

    exten => _X!,n(check),Goto(from-internal,${EXTEN},1)

  2. BKC November 3, 2017 at 2:19 pm

    Does this only work if unknown/blocked numbers are blocked? If so, how could it be modified to work without that option being turned on?

    • envoy510 November 18, 2017 at 10:55 pm

      @BKC not sure what you mean. You can duplicate those lines and add it to your own configuration, and it will block anything you want. Honestly, I’ve not been using this method for a while, since I get so many calls it’s just not feasible to block them this way. I only pick up my home line when I recognize the #, all else goes to voicemail.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: