1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If you had a PIAF Forum account in the vBulletin days, log in with your old credentials. Otherwise, sign up again and we'll get you back in business as soon as we can.
  3. A serious FreePBX vulnerability has been reported. Update your Framework Module immediately. Click here for details.

Anonymous CallerID filtering for inbound calls

Discussion in 'Add-On Install Instructions' started by jeremywillden, Mar 8, 2008.

  1. To go along with Ward's re-write of the Stealth Autoattendant, I re-wrote the anonymous call rejection contexts he had previously written and updated them for PiaF. I also made some effort to simplify integration with your dialplan so there is minimal scripting and most of the hooks are inside of FreePBX. (Most of the rewrite had to do with deprecated commands in the newest Asterisk code base :frown2: .) Here goes:

    Add this to the bottom of your /etc/asterisk/extensions_custom.conf, and change the extension number on Line 12 (bolded below) to match the extension of your main ring group (or main extension):

    [from-external-custom]
    exten => s,1,Zapateller(answer|nocallerid)
    exten => s,2,Wait(1)
    exten => s,3,SetMusicOnHold(default)
    exten => s,4,GotoIf($["${CALLERID(num)}" = ""]?who-r-u,s,1)
    exten => s,5,GotoIf($["foo${CALLERID(num)}" = "foo"]?who-r-u,s,1)
    exten => s,6,GotoIf($["${CALLERID(name):0:9}" = "Anonymous"]?who-r-u,s,1)
    exten => s,7,GotoIf($["${CALLERID(name):0:7}" = "Unknown"]?who-r-u,s,1)
    exten => s,8,GotoIf($["${CALLERID(num):0:7}" = "Private"]?who-r-u,s,1)
    exten => s,9,GotoIf($["${CALLERID(name):0:7}" = "Private"]?who-r-u,s,1)
    exten => s,10,GotoIf($["${CALLERID(num):0:10}" = "Restricted"]?who-r-u,s,1)
    exten => s,11,GotoIf($["${CALLERID(num):0:4}" = "PSTN"]?who-r-u,s,1)
    exten => s,12,Dial(Local/99@from-internal)
    exten => s,13,Hangup


    Don't forget to change the extension in line 12 above to the number of your main ring group (or main extension!).

    Next, add below this, still in /etc/asterisk/extensions_custom.conf (change your mailbox in line 7 to the main voicemail extension in your system):

    [who-r-u]
    exten => s,1,Background(privacy-unident)
    exten => s,2,Background(vm-rec-name)
    exten => s,3,Wait(2)
    exten => s,4,Record(/tmp/asterisk-stranger:gsm|5|15)
    exten => s,5,Background(pls-hold-while-try)
    exten => s,6,Goto(ext-park,70,1)
    exten => s,7,VoiceMail(105@default)
    exten => s,8,Playback(goodbye)
    exten => s,9,Hangup

    [ext-park]
    exten => 70,1,Answer
    exten => 70,2,SetMusicOnHold(default)
    exten => 70,3,Set(CALLERID(num)=100)
    exten => 70,4,Set(CALLERID(name)=Parked Call Info)
    exten => 70,5,ParkAndAnnounce(silence/4:asterisk-friend:/tmp/asterisk-stranger:vm-isonphone:at-following-number:pARKED|40|local/99@from-internal|who-r-u,s,7)
    exten => 70,6,Hangup


    In case you missed it above, don't forget to change line 7 above to reflect your main voicemail extension number (mine is 105) and the extension in 70,5.

    Save your changes and re-read configs.

    Now, to make this easy to integrate into your system, go to FreePBX and add a new CUSTOM extension (any extension number you want, I used 95, and I use the extension name PrivacyManager) and under Device Options, set the dial string to:

    Local/s@from-external-custom

    This directs any call to this extension to the script we put in the extensions_custom.conf file. Any call to this extension without a valid callerid gets sent through Ward's interrogation procedure, making the caller record their voice and then parking their call so you can decide to answer (or not).

    Save the extension (click submit). Now go to your inbound routes, and for any trunk that you want to screen, set the inbound route destination to the new PrivacyManager extension.

    I bet Ward's already working on re-writing this, and may be ready to post it on nerdvittles any day now, but I just couldn't wait. :D
    Enjoy!
    Jeremy
  2. wardmundy Nerd Uno

    You saved me the trouble. :smile5: If you don't mind, I'll share it in a future column with full credit to Y-O-U. Thanks!!
  3. tshif Guru

    Terrific! The family has (finaly) decided PBXIAF is to cool not to use for the home telephones also - and this will really work out well for that application. Thanks for the re-write - I cant wait to deploy this -

    Tony
  4. Modified version to use your own voice

    Don't mind a bit, Ward (just trying to contribute to the PiaF community at large) - bet you could make it even better with Cepstral... :cool: I'm modifying it for use with announcements recorded with my own voice, and if anyone wants to do the same, follow the version below:

    MAKE RECORDINGS:

    First, record yourself (I suggest using the system recordings interface in FreePBX and calling from an extension - just follow the instructions in FreePBX) saying:

    "Thank you for calling the (your name) residence. Your call appears to have no valid Caller ID. After the tone, say your name and press the pound key."

    (For the Brits in the audience, substitute "hash" for "pound" :smile5:)

    Save this recording with the name no-caller-id-message

    Make another recording saying:

    "Please hold while we connect your call."

    and save it as please-hold-connect

    Now another recording, saying:

    "We received an anonymous call from"

    and save it as anonymous-call-from

    And one more recording saying:

    "To accept this call, hang up the phone and dial"

    and save it as to-accept-this-call-dial

    One last recording:

    "otherwise, do nothing and the call will be transferred to voicemail"

    and save it as otherwise-voicemail

    Now modify these two contexts from the first example above, but do everything else as instructed before:

    [who-r-u]
    exten => s,1,Background(custom/no-caller-id-message)
    exten => s,n,Wait(1)
    exten => s,n,Record(/tmp/asterisk-stranger:wav|5|15)
    exten => s,n,Background(custom/please-hold-connect)
    exten => s,n,Goto(ext-park,70,1)
    exten => s,n,VoiceMail(105@default)
    exten => s,n,Playback(goodbye)
    exten => s,n,Hangup

    [ext-park]
    exten => 70,1,Answer
    exten => 70,2,SetMusicOnHold(default)
    exten => 70,3,Set(CALLERID(num)=71)
    exten => 70,4,Set(CALLERID(name)=Parked Call Info)
    exten => 70,5,ParkAndAnnounce(silence/1:custom/anonymous-call-from:/tmp/asterisk-stranger:custom/to-accept-this-call-dial:pARKED:custom/otherwise-voicemail|40|local/99@from-internal|who-r-u,s,6)
    exten => 70,6,Playback(custom/otherwise-voicemail)
    exten => 70,7,Hangup
  5. dad311 Guru

    I attempted to add your filter, but Asterisk does a restart just after xfer the call to the Parking lot.

    Here is my config, notice I changed line 6 for testing(VoicePulse issue). 200 is my default VM and extension 600 is my ring all. Thanks for any help.

    [from-external-custom]
    exten => s,1,Zapateller(answer|nocallerid)
    exten => s,2,Wait(1)
    exten => s,3,SetMusicOnHold(default)
    exten => s,4,GotoIf($["${CALLERID(num)}" = ""]?who-r-u,s,1)
    exten => s,5,GotoIf($["foo${CALLERID(num)}" = "foo"]?who-r-u,s,1)
    exten => s,6,GotoIf($["${CALLERID(name):0:9}" = "--"]?who-r-u,s,1)
    exten => s,7,GotoIf($["${CALLERID(name):0:7}" = "Unknown"]?who-r-u,s,1)
    exten => s,8,GotoIf($["${CALLERID(num):0:7}" = "Private"]?who-r-u,s,1)
    exten => s,9,GotoIf($["${CALLERID(name):0:7}" = "Private"]?who-r-u,s,1)
    exten => s,10,GotoIf($["${CALLERID(num):0:10}" = "Restricted"]?who-r-u,s,1)
    exten => s,11,GotoIf($["${CALLERID(num):0:4}" = "PSTN"]?who-r-u,s,1)
    exten => s,12,Dial(Local/600@from-internal)
    exten => s,13,Hangup


    [who-r-u]
    exten => s,1,Background(privacy-unident)
    exten => s,2,Background(vm-rec-name)
    exten => s,3,Wait(2)
    exten => s,4,Record(/tmp/asterisk-stranger:gsm|5|15)
    exten => s,5,Background(pls-hold-while-try)
    exten => s,6,Goto(ext-park,70,1)
    exten => s,7,VoiceMail(200@default)
    exten => s,8,Playback(Goodbye)
    exten => s,9,Hangup

    [ext-park]
    exten => 70,1,Answer
    exten => 70,2,SetMusicOnHold(default)
    exten => 70,3,Set(CALLERID(num)=100)
    exten => 70,4,Set(CALLERID(name)=Parked Call Info)
    exten => 70,5,ParkAndAnnounce(silence/4:asterisk-friend:/tmp/asterisk-stranger:vm-isonphone:at-following-number:pARKED|40|local/600@from-internal|who-r-u,s,7)
    exten => 70,6,Hangup


    Asterisk Log:
    [Mar 9 20:53:02] VERBOSE[28320] logger.c: -- Executing [70@ext-park:5] ParkAndAnnounce("Local/s@from-external-custom-b3e5,2", "silence/4:asterisk-friend:/tmp/asterisk-stranger:vm-isonphone:at-following-number:pARKED|40|local/99@from-internal|who-r-u|s|7") in new stack
    [Mar 9 20:53:02] VERBOSE[28320] logger.c: -- Dial Tech,String: (local,99@from-internal)
    [Mar 9 20:53:02] VERBOSE[28320] logger.c: -- Return Context: (who-r-u,s,7) ID: 100
    [Mar 9 20:53:02] VERBOSE[28320] logger.c: -- Started music on hold, class 'default', on Local/s@from-external-custom-b3e5,2
    [Mar 9 20:53:02] VERBOSE[28320] logger.c: == Parked Local/s@from-external-custom-b3e5,2 on 71@parkedcalls. Will timeout back to extension [who-r-u] s, 7 in 40 seconds
    [Mar 9 20:53:07] VERBOSE[28334] logger.c: Asterisk Event Logger Started /var/log/asterisk/event_log
    [Mar 9 20:53:07] VERBOSE[28334] logger.c: Asterisk Dynamic Loader Starting:
  6. I've looked at your configuration closely and I don't see any red flags, however, I found a capitalization mistake above (fixed now - the "goodbye" recording name used to be erroneously capitalized) but even with the error in the code it doesn't crash asterisk for me.

    Would you try this, in case it's a strange interaction with your provider, and see if it still tanks?

    Add this test extension to your extensions_custom.conf (in your from-internal-custom context), do a reload (asterisk -rx reload) and then dial 1236 from an internal extension. See if the crash still occurs and post the result here.

    exten => 1236,1,Zapateller(answer)
    exten => 1236,2,Wait(1)
    exten => 1236,3,SetMusicOnHold(default)
    exten => 1236,4,Goto(who-r-u,s,1)
    exten => 1236,5,Hangup

    Good luck!
    Jeremy
  7. dad311 Guru

    Some issue, I get the pls hold then Asterisks restarts.


    -- <SIP/203-0962d900> Playing 'beep' (language 'en')
    -- Executing [s@who-r-u:5] BackGround("SIP/203-0962d900", "pls-hold-while-try") in new stack
    -- <SIP/203-0962d900> Playing 'pls-hold-while-try' (language 'en')
    pbx*CLI>
    Disconnected from Asterisk server
    Executing last minute cleanups
  8. Maybe these are too obvious to check, but could you verify that:

    1. All the recordings used in the ParkAndAnnounce function are present in your ~asterisk/sounds folder?

    2. Do you have the Parking Lot module installed?
  9. dad311 Guru

    Yes, my parking lot module is installed and it works if I xfer there(and music plays). I believe all my sounds are installed, I have the basic PBXiAF installed with some of Wards addons, nothing custom. The last sound file I hear is "pls-hold-while-try", then asterisks restarts.
  10. dad311 Guru

    FYI, Might be related to this link. What version of Asterisk are your running?


    0011436: Calling parkandannounce from the dial plan causes Asterisk to core dump
  11. dad311 Guru

    Progress! (kind of). I was able to get this working after doing a source-update. After upgrading to Asterisk .18, Anonymous CallerID filtering worked, but my IVRs stopped. :banghead:
  12. That looks like the problem. I'm running 1.4.18. Good research! I'm assuming that when I ran update-source and recompiled that I got this version. I have a test IVR on my system that's still working. Try modifying it slightly and saving/applying the changes to see if a rebuilt FreePBX configuration helps.
    Jeremy
  13. tshif Guru

    This is one of those reallly cool things that gets others excited about the PBX project. I was right, at home this helped get pbxiaf adopted. Ha! :thumbsup:

    The only changes I have made is that we send the interrogation results to a page group instead of a ring group.
  14. dad311 Guru

    I tried a 2nd fresh "update-source" and got the same issue, IVRs stopped working. I tried making some small dummy edits with the IVRs, IN ROUTES and TIME CONDITIONS with no joy.

    Anyway it looks like .18 is a pre req for you script.
  15. wardmundy Nerd Uno

    The problem seems to be that update-source gets Asterisk up to 1.4.18, but it breaks .wav file support (typically used in IVR applications). We have recompiled this morning which restores .wav file support. Joe is still doing a little testing. Then we will post the quick fix. Stay tuned...
  16. wardmundy Nerd Uno

    I had exactly the same problem after updating to 1.4.18 so this is not a one-time quirk. We fixed my system by recompiling Asterisk and the .wav files started playing again. The steps to do that are shown below.

    BUT... before you do that, will someone try the following on a broken IVR system and see if either of these fixes your problem.

    First, run update-fixes and try your IVR again. Do the .wav files play?

    Second, chmod 777 /var/lib/asterisk/sounds/custom and try your IVR again.

    Third, if you've already run update-source and have 1.4.18 installed, here are the steps that worked for me to get the .wav files playing again:
    Code:
    cd /usr/src/asterisk
    amportal stop
    make clean
    ./configure
    make menuselect     (press x to accept defaults)
    make install
    reboot
    
    Fourth, if you haven't run update-source and want to manually install 1.4.18, here are the commands which are exactly the same in update-source:
    Code:
    cd /usr/src
    wget [URL]http://downloads.digium.com/pub/asterisk/asterisk-1.4-current.tar.gz[/URL]
    tar zxfv asterisk-1.4-current.tar.gz
    cd asterisk-1.4.18
    amportal stop
    make clean
    ./configure
     make
    make install
    reboot
    
    We await your reports to track down this gremlin. ;)
  17. dad311 Guru

    I did the update-source, broke my IVRs and then applied the update-fixes script. IVRs are working now!:smile5:. I also applied the CallerID filtering.:D thx
  18. dad311 Guru

    Now that I have everything working, how do I send my "non-filtered" calls back to my welcome IVR and not a ring group?

    thx
  19. dad311 Guru


    Figured it out:

    Incoming trunk > Welcome IVR >Welcome IVR i & t > ext 97.

    Perfect!
  20. FYI, I did an update-sources about a week ago (don't have the logs and the email log was deleted two days ago), which took me to 1.4.18 from [I think] 1.4.16. I didn't have any problems with wav files and my IVRs worked fine. In fact, I just checked my main IVR just now and it is working, just to be sure I didn't miss something.

Share This Page