Alter number before adding to blacklist

I have the module “Set CallerID” set up to change the incoming number so that if the call is missed the number is automatically prefixed with a “0” for calling with the correct outgoing caller ID (0 is my business number, nothing is private). When using the blacklist function to add the last incoming number (*32) this 0 is also added to the blacklist which results in the number not being banned.

Is it possible to strip the 0 and add to original incoming number to the blacklist?

Break down:

Incoming call: 012-3456789
Set callerID: 0012-3456789
Blacklisted number: 0012-3456789 => should be 012-3456789

I have thought about quering the database and changing numbers that match “00” periodically but I can’t seem to find the blacklist table in the MySQL database and I don’t think it would be wise to change the asterisk database file (sqlite).


How about adding some customized dialplan to the app-blacklist-custom context?

exten => *332,1,Goto(app-blacklist-last-special,s,1)

exten => s,1,Answer
exten => s,n,Macro(user-callerid,)
exten => s,n,Wait(1)
;Remove the first digit from the last caller id of the last called number to the extension
exten => s,n,Set(lastcaller=${DB(CALLTRACE/${AMPUSER}):1})
exten => s,n,GotoIf($[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]?noinfo)
exten => s,n,Playback(privacy-to-blacklist-last-caller&telephone-number)
exten => s,n,SayDigits(${lastcaller})
exten => s,n,Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=7)
exten => s,n,Playback(if-correct-press&digits/1)
exten => s,n,Goto(end)
exten => s,n(noinfo),Playback(unidentified-no-callback)
exten => s,n,Hangup
exten => s,n,Noop(Waiting for input)
exten => s,n(end),WaitExten(60,)
exten => s,n,Playback(sorry-youre-having-problems&goodbye)

exten => 1,1,Set(DB(blacklist/${lastcaller})=1)
exten => 1,n,Playback(num-was-successfully)
exten => 1,n,Playback(added)
exten => 1,n,Wait(1)
exten => 1,n,Hangup

Add these lines to the end of your /etc/asterisk/extensions_custom.conf file and reload the dialplan like this from the Linux console:

rasterisk -x'dialplan reload'

Then dial *332 to hit your special blocking caller id manipulation.

Thank you,

Daniel Friedman
Trixton LTD.

Thanks, will give that a try.