Block Spam Calls

Home » Asterisk Users » Block Spam Calls
Asterisk Users 11 Comments

Hi All. Does anybody know if Google/Android has an API I can sign up for that will allow us to query the caller ID and find out if it is spam or a robocaller? I ask because we’ve had increase in spam calls and I’d like to simply play dead air or something really annoying.

Thanks all, Alex

11 thoughts on - Block Spam Calls

  • I don’t think that there is a public (free) API. All robocall protection services are paid ones. You can find several on Twilio from US$ 0.003 up to US$ 0.06 per query, depending on what you are looking for.

  • Most spam calls are robocalls these days. At my house, I can block pretty much all of the robocalls by requiring the caller to take some action before ringing the phones. In our case, the action is just to dial 1 for my wife or 2 for me. The only difference it makes in the end is which voice mailbox the caller gets transferred to if no one answers, but since asterisk so programmable, there are a lot of ways to accomplish the basic concept. I can see tons of calls in my log that never get through to bother us.

    –Greg

  • Not bad. I was toying with another idea. I find that if I don’t answer a robot fast enough it just hangs up. How about ring two or three times before passing to the actual extension?


    D’Arcy J.M. Cain Vybe Networks Inc. A unit of Excelsior Solutions Corporation – Propelling Business Forward http://www.VybeNetworks.com/
    IM:darcy@Vex.Net VoIP: sip:darcy@VybeNetworks.com

  • D’Arcy Cain writes:

    You could try that and let us know, but I suspect:

    some robocallers don’t hang up so fast and will get through

    this will annoy the legit callers

  • I do this as well, but I also do a database lookup to see if the number is on our speeddial list and if so, pass the call directly on without the IVR prompts.

    Doug

  • Hello Doug,

    Friday, December 13, 2019, 11:03:37 AM, you wrote:

    I do something similar for calls without caller ID, but I was still getting robocalls with spoofed caller ID. I have now changed the dialplan slightly so that the first time people call they are asked to dial 1. After the first call, they are added to a known caller list and get straight through, and any robocalls at that point are blacklisted manually. I have found that most robocallers spoof the Caller ID so rarely call from the same number twice. It means that legitimate callers who cannot dial 1 just have to dial again to get through to the phones – there is a recorded message telling them to dial 1 or call back. I haven’t had a robocall since!

    The hardest thing about this was extracting all the numbers of previous callers from the CDR and adding it to the Previous_Callers AstDB for the lookup. I didn’t want to make existing callers go through the initial learning process.


    Best regards, Julian mailto:jb_soft@trink.co.uk

  • Mind posting your dialplan code?  I was thinking the same thing – very much like an old spam control program I used to use whose name now escapes me.  First time senders would have to respond to an auto-reply, then were added to a whitelist.

    This would be a great FreeBSD module…

    Cheers,

    *Jeff LaCoursiere*
    STRATUSTALK, INC. / CTO

    Phone: *+1 703.496.4990 x108*
    Mobile: *+1 815.546.6599*
    Email: *jeff@stratustalk.com*
    Website: *https://www.stratustalk.com*
    Address: *

  • For those that would like to see my code:

    exten => 517xxxxxxx,1,Answer()
        same => n,Gosub(check_blacklist,s,1)
        same => n,Gosub(get_callerid,s,1)
        same => n,Gosub(check_for_direct,s,1)
        same => n,Set(CHANNEL(musicclass)=music)
        same => n,Gosub(extension_timeouts,s,1)
        same => n,Dial(SIP/3501,${timeout.timeout},TtKk)
        same => n,NoOP(Dial Status: ${DIALSTATUS})
        same => n,NoOP(Hangup Cause: ${HANGUPCAUSE})
        same => n,Gosub(s-${DIALSTATUS},s,1)

    [check_for_direct]

    ;**********************************************************************
    ;* Check if there is a match of the inbound call to the speed dial list
    ;* If not, make then go through the IVR menu
    ;*******************************************

    exten =>
    s,1,Set(ARRAY(speed.phone,speed.name)=${ODBC_MENU_DIRECT(drdos,${CALLERID(number)})})

    ;********************************************************
    ;* If the contents of speed.phone is blank, assume that it
    ;* is not programmed and force the call to use the IVR to
    ;* prove they are not an automated call.
    ;********************************************************

         same => n,GotoIf($[“${speed.phone}” != “” ]?3:ivr_menu,s,1)
         same => n,NoOP(${speed.name} is on the approved list)
         same => n,Return()
         same => n,Hangup()

  • Hello Jeff,

    Friday, December 13, 2019, 7:42:38 PM, you wrote:

    This is not the neatest of code segments, as there are a few checks I
    make before I let calls through to the phones:

    (1) It checks for blacklisted callers, and sends them off to a go-away message

    (2) It checks whether there is Caller ID information, and sends sends anon calls to another handler (again asking callers to press 1 or leave a message) but there is also a switch to just send them to voicemail: I had a problem with 1 anon caller phoning repeatedly a few years ago, and that was the solution!

    (3) For calls with a CID number, it checks whether these have called before and if not, adds them to the previous caller db then sends them to an IVR to play them a message and ask them to press a key (this means that if they call again, they will always go through to the phones, as a number of genuine callers cannot, or won’t, dial 1 – if they turn out to be a robocall, they are blacklisted)

    (4) Calls that pass all the tests go through to the phones

    I am sure that I could make the code much more efficient, but it has not been a priority and I have been adding features as I need them, rather than re-writing!

    [from-pstn] (initial handler for PSTN calls)
    exten => s,1,Log(NOTICE, Incoming PSTN Call from CDR ${CDR(src)} and CID ${CALLERID(name)})
    exten => s,n,GotoIf(${DB_EXISTS(blacklist/${CDR(src)})}?block) ; Check whether caller blacklisted exten => s,n,Set(DB(callers/lastcall)=${CDR(src)})
    exten => s,n,Set(GLOBAL(CALLEDLINE)=L1-)
    exten => s,n,GotoIf($[“${CDR(src)}” != “”]?toincoming) ; if there is valid CID go to IncomingHome exten => s,n,GotoIf($[“${CALLERID(name)}” = “WITHHELD”]?nocid) ; if anon call… exten => s,n,GotoIf($[“${CALLERID(name)}” = “INTERNATIONAL”]?nocid)
    exten => s,n,GotoIf($[“${CALLERID(name)}” = “UNAVAILABLE”]?nocid)
    exten => s,n,GotoIf($[“${CALLERID(name)}” = “PAYPHONE”]?nocid)
    exten => s,n,GotoIf($[“${CDR(src)}” = “”]?drop)
    exten => s,n(toincoming),GotoIf(${DB_EXISTS(previous/${CDR(src)})}?:unknown) ; Check whether caller has rung before exten => s,n,GoSub(IncomingHome,s,1) ; answer the call in the macro exten => s,n(nocid),GotoIf($[ $[ “${DB(variables/ANONTOVM)}” = “1” ] ]?vm) ; …check whether anon goes straight to vm exten => s,n,GoSub(IncomingHome,s,1) ; answer the call in the macro exten => s,n(block),GoSub(Handler-MarketingCall,s,1) ; deal with blacklisted callers exten => s,n(vm),Log(NOTICE, No CID data or AnontoVM set) ; send anon callers to AnonCall IVR
    exten => s,n,Goto(AnonCall-menu,s,1)
    exten => s,n(unknown),Log(NOTICE, Unknown caller to IVR) ; send unknown callers to UnknownCaller IVR
    exten => s,n,Set(DB(previous/${CDR(src)})=1) ; add number to previous caller DB
    exten => s,n,GoSub(UnknownCaller-menu,s,1,(${CDR(src)}))
    exten => s,n(drop),Log(NOTICE, No CID data, call dropped) ; drop calls with no CID info exten => s,n,Wait(15)
    exten => s,n,Hangup()

    [UnknownCaller-menu] ; The Unknown caller IVR – with some logging of call volumes

    exten => s,1,Log(NOTICE,Unknown Caller ${ARG1} – Caller to IVR)
    exten => s,n,Verbose(2,Anon Calls = ${DB(unknown/total)} Total, ${DB(unknown/valid)} Valid, ${DB(unknown/invalid)} Invalid)
    exten => s,n,Set(unknown=$[${DB(unknown/total)} + 1])
    exten => s,n,Set(DB(unknown/total)=${unknown})
    exten => s,n,Verbose(2,Unknown Calls set to ${DB(unknown/total)})
    exten => s,n,Answer(500)
    exten => s,n(loop),Background(unknown)
    exten => s,n,WaitExten()
    ; 1 – Call to incoming call handler exten => 1,1,NoOp(Real caller progressing)
    exten => 1,n,Log(NOTICE,Unknown Call – Caller dialled to continue to phones)
    exten => 1,n,Set(valid=$[${DB(unknown/valid)} + 1])
    exten => 1,n,GoSub(IncomingHome,s,1)
    exten => 1,n,Hangup()
    ; 2 – invalid entry exten => i,1,Playback(invalid)
    exten => i,n,Log(NOTICE,Unknown Call – Caller dialled invalid number)
    exten => i,n,Set(invalids=$[${DB(unknown/invalid)} + 1])
    exten => i,n,Set(DB(unknown/invalid)=${invalids})
    exten => i,n,Goto(s,loop)
    ; 3 – timeout exten => t,1,Playback(invalid)
    exten => t,n,Log(NOTICE,Unknown Call – Caller timed out)
    exten => t,n,Set(invalids=$[${DB(unknown/invalid)} + 1])
    exten => t,n,Set(DB(unknown/invalid)=${invalids})
    exten => t,n,GoSub(subMessaging,s,1,(${ARG1}),(“Unknown”))
    exten => t,n,Hangup()


    Best regards, Julian mailto:jb_soft@trink.co.uk

  • Hi All. Thank you so much for all the feedback; it is really helpful. I
    found a company out there that specializes in Asterisk solutions and has a Robocall/SPAM call solution specifically for Asterisk. We give it a spin last week and it turned out great. It’s not free, but works very well and I think it is worth passing it on. Here’s the site for the service –
    https://www.tiltx.com/asterisk-robocall-blocker.

    I thought I’d pass this along as it has taken me some time to find something for Asterisk that actually works.

    Hope this helps, Alex