Block Caller by CALLERID(name) in blacklist.conf

I have a file named blacklist.conf that all incoming calls must access before continuing the current extension. So far it has worked for blacklisting unwanted callers. Currently I have a nuisance call center that won’t stop calling, I’m not sure if there selling/scamming or what, However they keep spoofing the CALLERID(num) and it’s almost impossible to block them. The caller also changes up the CALLERID(name) but stays within a certain format that can be pattern matched.

Here is an example of the caller name X2050127171544859521. I found a piece of code that looks like it might do the trick if modified correctly, however I’m not sure how to do the pattern match correctly in asterisk.

Here’s the code I found that needs modified.
exten => s,1,GotoIf(["{CALLERID(name)}" = “FOO INC”]?blacklisted)

Here is my attempt to modify the code to run in my blacklist.conf file. I’m not sure if it will work.
exten => s,1,GotoIf(["{CALLERID(name)}" =~ /X\d+/]black,blocked,1)

;BEGIN FILE blacklist.conf
[blacklist]

exten => s/_121255512XX,1,Goto(black,blocked,1) ; Credit Card Scammer

; Returns to and completes preivous extentions script if no blocked callerids
exten => _.,1,Return()

[black]
exten => blocked,1,NoOp(Blocked Call)
same => n,Playback(silence/1)
same => n,Zapateller
same => n,playback(were-sorry&discon-or-out-of-service)
same => n,Hangup
;END FILE

Traditionally this is where AGI/FastAGI has come in really handy. Dialplan logic can become quite complex and painfully fragile over time with all of the one-offs.

Consider this for a moment:
exten => s,1,AGI(check_blacklist.py)

the python (or lua, perl, php, tcl, bash etc.) script checks your blacklisted numbers and name patterns and optionally sets a channel variable IS_BLOCKED to “blocked”

same => n,GotoIf(["{IS_BLOCKED} = “blocked”]?blocked)

It is good method, I use to do that

I’m new to asterisk and not sure to some of the syntax.

Will this exten =>; s,1,GotoIf(["{CALLERID(name)}" =~ /X\d+/]black,blocked,1) work to block this caller name X2050127171544859521. If it will is there another way to write exten => s,1, so I can add multiple lines as needed.

This isn’t for a business so I don’t expect the flat file to get very big.

Use a girl friend logic

ex - girlfriend logic

Also start reading about the Home - Asterisk Documentation