TUTORIAL Anonymous CallerID filtering for inbound calls

Joined
Feb 22, 2008
Messages
152
Reaction score
0
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
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
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!!
 

tshif

Guru
Joined
Jan 3, 2008
Messages
1,240
Reaction score
4
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
 
Joined
Feb 22, 2008
Messages
152
Reaction score
0
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
 

dad311

Guru
Joined
Jan 13, 2008
Messages
604
Reaction score
2
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:
 
Joined
Feb 22, 2008
Messages
152
Reaction score
0
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
 

dad311

Guru
Joined
Jan 13, 2008
Messages
604
Reaction score
2
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
 
Joined
Feb 22, 2008
Messages
152
Reaction score
0
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?
 

dad311

Guru
Joined
Jan 13, 2008
Messages
604
Reaction score
2
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.
 

dad311

Guru
Joined
Jan 13, 2008
Messages
604
Reaction score
2
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
 

dad311

Guru
Joined
Jan 13, 2008
Messages
604
Reaction score
2
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:
 
Joined
Feb 22, 2008
Messages
152
Reaction score
0
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
 

tshif

Guru
Joined
Jan 3, 2008
Messages
1,240
Reaction score
4
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

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.
 

dad311

Guru
Joined
Jan 13, 2008
Messages
604
Reaction score
2
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

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.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
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...
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
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. ;)
 

dad311

Guru
Joined
Jan 13, 2008
Messages
604
Reaction score
2
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. ;)

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
 

dad311

Guru
Joined
Jan 13, 2008
Messages
604
Reaction score
2
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
 

dad311

Guru
Joined
Jan 13, 2008
Messages
604
Reaction score
2
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


Figured it out:

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

Perfect!
 
Joined
Nov 19, 2007
Messages
180
Reaction score
8
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.
 

Members online

No members online now.

Forum statistics

Threads
25,779
Messages
167,505
Members
19,199
Latest member
leocipriano
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top