<div dir="ltr">Sorry, Gmail took my conversation with John off-list somehow,  I'll repost what I had set here (sorry, it's going to be a bit big now), and I will be more careful in the future:<div><br></div><div>First part:</div><div><br></div><div><span style="font-size:12.8px">I'm using Grandstream phones, so I have XML soft-keys, what hardware do you have and how good are you with dialplans?  You'll have to do some re-work unless you have an exact match for my setup.  I'm doing my best to give you the functional code, I have to change a bunch of stuff to not leak the security things I do in my code and some of the way more involved stuff I do.  this should at least get you running I think.  Portions between "CODE:  /CODE" tags are the functional dialplan code, I tried to comment a lot here to explain what's happening, but I may have broken something in the process.  Also, be aware that I generate custom sound files, so if you try to run the code and it throws an error about sound-file does not exists, that's why.</span><div style="font-size:12.8px"><br></div><div><span style="font-size:12.8px">For this, I am using the internal DB in Asterisk (</span><a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+Internal+Database" target="_blank" style="font-size:12.8px">https://wiki.asterisk.org/<wbr>wiki/display/AST/Asterisk+<wbr>Internal+Database</a><span style="font-size:12.8px">).</span><br><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">The first part is easy, but also very important - filter your Caller-ID data (in computers, we NEVER trust data from a source we don't generate), CODE:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div>[incommingcall]</div><div>exten => 15555551234,1,Set(<wbr>CalledNumber=${15555551234})               ; Primary incoming phone line, number changed to protect my phone number</div><div>same => Set(CallEventTime=${STRFTIME($<wbr>{EPOCH},,%m-%d-%Y_%H.%M.%S)}</div><div>same => n,Set(CALLERID(name)=${FILTER(<wbr>A-Z0-9\s,${CALLERID(name)})})</div><div>same => n,Set(CALLERID(num)=${FILTER(<wbr>0-9,${CALLERID(num)})})</div><div>same => n,Verbose(Incomming call to main phone number)</div><div>same => n,Goto(IVR-Menu,IVRStart,1)</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">/CODE - Then you hit phone numbers that don't have caller ID with the special three-tone application that sounds like a phone company message, CODE:</div><div style="font-size:12.8px"><div><br></div><div>[IVR-Menu]</div><div>exten => IVRStart,1,Zapateller(<wbr>nocallerid)                 ; Before answering we do the sound for no-caller ID calls</div><div>same => n,Zapateller(answer,<wbr>nocallerid)                    ; This is where the phone call gets answered, we hit no-caller ID calls again here</div><div>same => n,Wait(1)</div><div>same => n,Playback(call-recording-<wbr>warning)              ; Legally required message: "For quality control purposes, this call may be monitored."</div><div>same => n,Wait(2)</div><div>same => n,Monitor(wav,Inbound_to_${<wbr>CalledNumber}_from_${CALLERID(<wbr>num)}_${CallEventTime})  ; Yes, I record every call in an out.<br></div><div>same => n,GotoIf($["${CalledNumber}" != "15555551234"]?<wbr>BlacklistFilter)  ; Number changed to protect my toll-free costs!!!</div><div><br></div><div>/CODE - I had a problem with political phone calls to my 855 number this past spring, so I added this little routine to prompt the caller for a single random digit to be entered to prove they could interact, that stopped all the calls from getting through.  CODE:</div><div><br></div><div>; special human test for toll-free<br></div><div>same => n,Set(TOLLFREERAND=${RAND(0,9)<wbr>})</div><div>same => n,Read(HUMANTEST,thank-you&<wbr>human-test&${TOLLFREERAND}&<wbr>now,1,,1,5)   ; Says "Thank you. If you're a human, please press the number: {RANDOM}, now.", like a captcha.</div><div>same => n,GotoIf($["${HUMANTEST}" = "${TOLLFREERAND}"]?<wbr>BlacklistFilter) ; If the random number matches what they entered they move on in the dialplan</div><div>same => n,Playback(do-not-call-<wbr>warning)                   <br></div><div><div>; I have a message that states when this number was added to the FTC do-not-call list,</div><div>; requests removal of the number from the current list, and warns that the call and information was recorded<br></div><div>; and will be turned over to the FTC if the calls continue.</div></div><div>same => n,Hangup()  ; Yes, if a human can't be bothered to press one button when calling a number I pay the minutes for, I won't be bothered to talk to them.</div><div><br></div><div>/CODE - now we can get into the stuff that handles the blacklists and telemarketers.  CODE:</div><div><br></div><div>; return to regular program<br></div><div>same => n(BlacklistFilter), Verbose(Checking caller ID against blacklist)</div><div>same => n,GotoIf($[DB_EXISTS(<wbr>blacklist\${CALLERID(num)})]?:<wbr>TelemarketerFilter) ; If the caller ID is not in the blacklist DB family, it goes to the telemarketer check</div><div>same => n,VoiceMail(Blacklist@<wbr>OtherAccounts,s)</div><div>same => n,Hangup()</div><div>same => n(TelemarketerFilter), Verbose(Checking caller ID against telemarketer list)</div><div>same => n,GotoIf($[DB_EXISTS(<wbr>telemarketer\${CALLERID(num)})<wbr>]?:IVRInteractiveStart) ; If the caller ID is not in the blacklist DB family, it goes to the telemarketer check<br></div><div>same => n,VoiceMail(Telemarketer@<wbr>OtherAccounts,s)</div><div>same => n,Hangup()</div><div><br></div><div>/CODE: Then if the caller ID is not on either list, they go into the start of the IVR.  Everything up until now takes about 8 seconds, I limit "appeal" voicemails to 30 seconds by account limit, so that if one managed to come in through my toll-free number, it wouldn't finish the first minute of billing.  CODE:</div><div><br></div><div>same => n(IVRInteractiveStart),<wbr>Verbose(Dialplan continues here)</div><div>;</div><div>; ...redacted...</div><div>;</div><div>same => n,Hangup()<br></div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">/CODE.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">You'll have to tell me more about your phones to know what you are doing with called user prompts.  You can enter the numbers into the DBs manually from the console using the DB commands: <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+Internal+Database" target="_blank">https://wiki.<wbr>asterisk.org/wiki/display/AST/<wbr>Asterisk+Internal+Database</a></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I hope this makes sense...</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Second part:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><span style="font-size:12.8px">One more thing, I didn't mention when I cut down the code, which is good food for thought - I also have a "whitelist" for friends and family.  This is the better way for a public facing phone number, people you know who will call you, you can skip most of the boring stuff if you "trust" the source phone number.</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I do call screening on all incoming calls, unless they are on the whitelist.  How that works is similar, I screen once if it's a new number, and the file-name of the name they said during the screening recording is saved to the the whitelist DB as:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">CODE:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">same=>n,Set(DB(whitelist\${<wbr>CALLERID(num)}=${<wbr>FILENAMEASVALUE}))</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">/CODE</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">That way when I get connected the next time they call, I get a phone call from the home phone system, and instead of playing the screening prompt, I get: "Connecting you to {recorded name}"</div><div style="font-size:12.8px"><br></div><div class="gmail_extra" style="font-size:12.8px">For a custom find-me-follow-me function, I wrote a menu that uses the 5 options:</div><div class="gmail_extra" style="font-size:12.8px">1 = Connect me</div><div class="gmail_extra" style="font-size:12.8px">2 = Connect me, add to whitelist</div><div class="gmail_extra" style="font-size:12.8px">5 = Send to my Voicemail</div><div class="gmail_extra" style="font-size:12.8px">7 = Add to Telemarketer list</div><div class="gmail_extra" style="font-size:12.8px">9 = Add to Blacklist</div><div class="gmail_extra" style="font-size:12.8px"><br></div><div class="gmail_extra" style="font-size:12.8px">That's done in a Macro and you could do that with basically any phone.  So my basic process (with several omissions) is:</div><div class="gmail_extra" style="font-size:12.8px"><br></div><div class="gmail_extra" style="font-size:12.8px">* New Incoming call</div><div class="gmail_extra" style="font-size:12.8px">* Set up and filter variables</div><div class="gmail_extra" style="font-size:12.8px">* Start a recording</div><div class="gmail_extra" style="font-size:12.8px">* If it's a toll-free, do a "captcha" human-test</div><div class="gmail_extra" style="font-size:12.8px">* Check if they are on the whitelist, if they are skip to the IVR<br></div><div class="gmail_extra" style="font-size:12.8px">* Get rid of the new "easy" telemarketers</div><div class="gmail_extra" style="font-size:12.8px">* Check if they are on the blacklist, get rid of them if they are</div><div class="gmail_extra" style="font-size:12.8px">* Check if they are a known Telemarketer, get rid of them if they are</div><div class="gmail_extra" style="font-size:12.8px">* Ask for the extension/user<br></div><div class="gmail_extra" style="font-size:12.8px">* On user answer, If on the whitelist connect, if not screen</div><div class="gmail_extra" style="font-size:12.8px">* If no answer, take a message.</div><div class="" style="margin:2px 0px 0px;font-size:12.8px"><div id=":2km" class="" tabindex="0"><img class="" src="https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif"></div></div><span class="" style="font-size:12.8px"><font color="#888888"><div class="gmail_extra"><span style="font-size:12.8px">-T</span><br></div></font></span></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">END OF REPOST...</div><div style="font-size:12.8px"><br></div><div><span style="font-size:12.8px">Thread should be caught back up now (again, very sorry!!!).</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I hadn't gotten to the Macro, as John hasn't responded yet anyway.</span><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Kevin what phones are you using?  Depending on how your phones work, there are various way to get this to happen.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">If your phones don't have hot keys, a quick and dirty way to "kiss-off" unwanted callers is to create an extension that an internal-called-user can transfer the caller to.  You can even use a "dumb" touch-tone phone that way.</span></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Best,</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">-Tim</div><div style="font-size:12.8px"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 29, 2016 at 2:31 PM,  <span dir="ltr"><<a href="mailto:kc6ovd@gmail.com" target="_blank">kc6ovd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US" link="blue" vlink="#954F72"><div><p class="MsoNormal">Tim, I would like to see the code for this. I also am a home user and I have been thinking of how I would do this same type of thing. Right now I have a black list db and it is manual. When the unwanted caller calls they go to a no one is here go away message and splash they are gone.  Your method and hot keys sounds very cool.</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">-Kevin<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986" target="_blank">Mail</a> for Windows 10</p><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p><div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in"><p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:tim.strommen@gmail.com" target="_blank">Tim S</a><br><b>Sent: </b>Monday, August 29, 2016 12:40 PM<br><b>To: </b><a href="mailto:asterisk-users@lists.digium.com" target="_blank">Asterisk Users Mailing List - Non-Commercial Discussion</a><br><b>Subject: </b>[asterisk-users] Blacklist callers from file</p></div><div><div class="h5"><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">I'm a home user (not business), but I implemented a blacklist function too after a harassing call to my wife.</span><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u><u></u></span></p><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">Using the Asterisk DB functions, I have a caller ID look-up function before my IVR-tree starts, a simple if then.  Lookup caller ID in blocked-caller DB, if found then I kick them to a short dialplan the plays a message telling them they've been blocked, then lets them record an "appeal" message.  If a user put someone in the Blocked DB, by accident, I'd want to have a way for someone to report it to me via phone.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">To add a number to the Blocked DB, the caller internal user is allowed a hot-key on the phone to block the caller in-call, or with screening they are given an option in the prompt.  When a new number is added to the Blocked DB, the call recording for the session is retained to be able to remember why it was blocked.  The Blocked DB will automatically unblock an entry after a year, to account for number changes, but the entry can be extended before it expires via an email response.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">I did a similar thing for Telemarketers, the phone numbers also automatically unblock, but only after a month, as most of the worst offenders I've come across don't stay with a phone number longer than a few weeks to avoid enforcement by the FTC.  For that I also have a hot key on the phones for "Telemarketer Goodbye", which adds to the DB while playing a "Remove me from your list and stop bothering me" message.  This gives my users a bit of power as they don't have to be polite, or think of an evasion to the sales person, they just need to push a button and hang up the phone when they realize is a sales call.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">I didn't want to publish code for this since it's a bit long winded, but it should give you some ideas of things you want to consider.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">Best,<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">-Tim<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p><div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">On Mon, Aug 29, 2016 at 9:20 AM, John Kiniston <<a href="mailto:johnkiniston@gmail.com" target="_blank">johnkiniston@gmail.com</a>> wrote:<u></u><u></u></span></p><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in"><div><div><p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:12pt;font-family:"Times New Roman",serif">Here is a quick and dirty bash script to do it that I wrote you.<br><br>#!/bin/bash<br>if ( asterisk -rx "database deltree blacklist")<br>        then<br>                echo "Blacklist Cleared"<br>        else<br>                err "ERROR Failed to clear Blacklist, Exiting."<br>                exit 1;<br>fi<br><br>while IFS=, read TN REASON<br>do<br>if ( asterisk -rx "database put blacklist \"${TN}\" \"${REASON}\"")<br>   then<br>           echo "Inserted $TN $REASON to Blacklist"<br>   else<br>         err "ERROR Insert Failed on $TN."<br>         exit 1;<br>fi<br><br>done < blacklist.csv<br>unset IFS<br><br><u></u><u></u></span></p></div><p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:12pt;font-family:"Times New Roman",serif">It reads from the file blacklist.csv in the same directory with the format of NUMBER,"DESCRIPTION/REASON"<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">On Sat, Aug 27, 2016 at 8:59 AM, tux john <<a href="mailto:atux@null.net" target="_blank">atux@null.net</a>> wrote:<u></u><u></u></span></p><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in"><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif">Hi. I would like to blacklist a few callers and I have been using the *CLI> database put blacklist 1234 "annoying callers". Instead of putting the same command for every user is there any way to have a file? Ideally a file in /opt that I would update the blacklisted numbers (add,remove). Is there anything like that, please?<br><br>--<br>______________________________<wbr>______________________________<wbr>_________<br>-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br><br>Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016<br>      <a href="http://www.asterisk.org/community/astricon-user-conference" target="_blank">http://www.asterisk.org/<wbr>community/astricon-user-<wbr>conference</a><br><br>New to Asterisk? Start here:<br>      <a href="https://wiki.asterisk.org/wiki/display/AST/Getting+Started" target="_blank">https://wiki.asterisk.org/<wbr>wiki/display/AST/Getting+<wbr>Started</a><br><br>asterisk-users mailing list<br>To UNSUBSCRIBE or update options visit:<br>   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/<wbr>mailman/listinfo/asterisk-<wbr>users</a><u></u><u></u></span></p></blockquote></div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif;color:rgb(136,136,136)"><br><br clear="all"><br>-- <u></u><u></u></span></p><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif;color:rgb(136,136,136)">A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.<br>---Heinlein<u></u><u></u></span></p></div></div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><br>--<br>______________________________<wbr>______________________________<wbr>_________<br>-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br><br>Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016<br>      <a href="http://www.asterisk.org/community/astricon-user-conference" target="_blank">http://www.asterisk.org/<wbr>community/astricon-user-<wbr>conference</a><br><br>New to Asterisk? Start here:<br>      <a href="https://wiki.asterisk.org/wiki/display/AST/Getting+Started" target="_blank">https://wiki.asterisk.org/<wbr>wiki/display/AST/Getting+<wbr>Started</a><br><br>asterisk-users mailing list<br>To UNSUBSCRIBE or update options visit:<br>   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/<wbr>mailman/listinfo/asterisk-<wbr>users</a><u></u><u></u></span></p></blockquote></div></div></div></div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></blockquote></div><br></div></div></div>