Help with setting spam filter

PBX Version: 14.0.16.4
PBX Distro: 12.7.8-2012-1.sng7
Asterisk Version: 16.13.0

We have been using a simple IVR to stop spam calls. I would like to allow some numbers to skip the IVR to reach a human. I saw the post by lgaetz Of Robocalls and Whitelists and we would like to use it. I installed the Dynamic Routes and added the lgaetz-cmcheck.php file to /var/lib/asterisk/agi-bin/ folder and chenged the file permission to asterisk:asterisk.
I appreciate help in the next steps:

Field name Value
Dynamic Route Name Allowed DID
Dynamic Route Description Allowed DID
Enable DTMF Input No
Announcement None
Timeout blank
Validation blank
Invalid Retries blank
Invalid Retry Recording None
Invalid Recording None
Invalid Destination Do not set this value
Saved input varibale name None
Saved result variable name None
Source Type AGI
AGI Lookup lgaetz-cmcheck.php
AGI Result Variable True,False
Default Destination IVR: Welcome
Dynamic Route Entries Match: False; Destination: IVR: Welcome
Match: True; Destination: Ring group
  • Do the above Dynamic Routes values looks right?

  • Do I need to add the code below to extensions_custom.conf

         [check-whitelist]
         exten => s,1,Noop(Entering user defined context [check-whitelist] in extensions_custom.conf)
         exten => s,n,AGI(lgaetz-cmcheck.php,${CALLERID(number)})
         exten => s,n,gotoif($["${whitelist}"="false"]?ivr-1,s,1)    ; edit for wherever non-whitelisted calleres should go
         exten => s,n,Return
    
  • Is there anything I need to do?

Thanks for your help and input.

1 Like

Hi Moussa

The script has to be executable in addition to being owned by asterisk

chmod +x /var/lib/asterisk/agi-bin/lgaetz-cmcheck.php

You have to config the AGI line with:

lgaetz-cmcheck.php,${CALLERID(number)} 

and the result variable with

whitelist

When it’s working correctly, the console output will look like:

-- Executing [s@dynroute-3:1] AGI("SIP/6002-00000005", "agi://127.0.0.1/lgaetz-cmcheck.php,6002 ") in new stack
-- Remote UNIX connection
-- Remote UNIX connection disconnected
-- agi://127.0.0.1/lgaetz-cmcheck.php,6002 : Searching all Contact Mgr groups for 6002
-- agi://127.0.0.1/lgaetz-cmcheck.php,6002 : Found 6002 in Contact Mgr
-- agi://127.0.0.1/lgaetz-cmcheck.php,6002 : Setting Asterisk channel var whitelist to true
-- <SIP/6002-00000005>AGI Script agi://127.0.0.1/lgaetz-cmcheck.php completed, returning 0
-- Executing [s@dynroute-3:2] Set("SIP/6002-00000005", "dynroute=true") in new stack
2 Likes

Thank you @lgaetz. It is working, I want to mention that the true and false matches were case sensitive. Great software.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.