Conditional Blacklist?

Hello!

This is rather painful to ask because I generally love my customers… However, many of the callers we calling during high volume times refuse to leave messages, opting instead to simply hang up and immediately call back again and again.

Is there a feature that I can use to automatically direct repeat calls within, say, a five minute window away from my reception ring group and into our voicemail system so my team can work without the distraction?

Something like a blacklist, but that adds and removes IDs based on the number of times they attempt to call within a given time window. I understand this will be limited to those who do not block their callerID.

drnate

If you have redis installed, I’d do something like this.

Create a tiny bash script to keep track of the amount of calls within 5 minutes

#!/bin/bash

phone_number="$1"

if [ -z "$phone_number" ]; then
    echo "Usage: $0 <phone_number>"
    exit 1
fi

# Increment the counter for the phone number
value=$(redis-cli INCR "$phone_number")

# Set/refresh expiration to 300 seconds
redis-cli EXPIRE "$phone_number" 300 >/dev/null

# Check rate and print action
if [ "$value" -ge 5 ]; then
    echo "block"
else
    echo "continue"
fi

Create a custom destination with the destination time-based-block,s,1 and set the return destination to the queue.

Then, create a dialplan that does something like this:

[time-based-block]
exten => s,1,Noop(Check if we need to prevent ${CALLERID(all)} from reaching the queue)
 same => n,GotoIf($["${SHELL(/path/to/script.sh ${CALLERID(num)})}"="block"]?block)
 same => n,Return()
 same => n(block),Goto(from-internal,vmu1234,2)

I did not test this, but this should do the trick.

Let me know if you have any questions.

OK. I may have misread your post. The solution I posted was to divert specific repeaded callers.

If you want to allow your reception to simple “Pause” all calls. Then there are multiple way to do it.

One would be, simply logging out of the queue, another would be to use a Call Flow Control and a BLF to toggle where calls are going.

But if you want this to auto reset after 5 minutes, then you’ll have to use a custom dialplan.

Perhaps if you can elaborate on exactly what you are looking for.

@PitzKey - I think your first solution is the one I want.

  1. Caller calls, rings reception group and after max time ringing is routed to voicemail because reception team is busy.
  2. Caller hangs up and calls back
  3. After the second callback (to allow for some grace), caller is sent directly to voicemail (reception group does not ring.
    4) After 5 minutes, caller can call and ring reception group again
    – Will the script handle more than one caller? For example if two or three of them are calling and calling and calling?
    Thank you!

The way it works is, that it creates a key/value in redis and sets an expiration of 300 seconds for the pair. The key is the caller ID and the value starts with 1 and is incremented every time that caller calls, as well as it updates the expiration to another 300 seconds.

So that timer and blocking is unique for each caller ID.

You know what I would do ? I would create a message that tells them what they are doing is not actually helping but in fact slowing you down. Just temporarily blacklisting them will not change the behavior, in fact it might make it worse, or they go online to FB or yelp or someplace and just start complaining to the world that you never answer the phones.

I would record a system message that sort of sounds like you answered the phone. “HI ! Hey, listen,I know you are eager to talk to someone, but calling and hanging up over and over is really distracting, and it actually slows us down. The reason it went to voice mail is because we are already on the phone with someone else. Calling right back within 2 or 3 minutes and hanging up again does not actually help us to complete our other call faster.”

OP mentioned that he wants to send these calls to voicemails. He can indeed record a greeting that would play to the caller prior to reaching the voicemail.

So if I am following this right, callers are not leaving a message went sent to voicemail but hang up to call again. The solution is to send them directly to voicemail instead?

How does this make them leave a voicemail at this point? Wouldn’t a queue be a better option?

Right now, we just want the phone to quit ringing on our end. I haven’t explored queues yet, but that may be a worthwhile exercise, human behavior being as it is. It looks like I can just update the dialplan to send these callers wherever we eventually decide. We have done well training our clients to use the voicemail - there are some who simply refuse to leave a message.
My “intro message” will say something about how we are helping others right now and calls are being directly sent to voicemail. You can try again in 20 minutes, or leave a message now and we will call you back. I don’t have the details worked out yet but certainly don’t want to inflame the situation by insinuating they are being rude.
I am going to need a couple of weeks to set this up and try it out. I will keep the thread up to date. I appreciate your insight into FreePBX and the options it offers to help us out. Thank you!

Thank you again for your help.
@PitzKey
After reviewing the different options, I would like the dialplan to direct the callers to an IVR that gives them our standard voicemail options. I think we change the last line of the dialplan, but I can’t figure out what to change to. The IVR is called ReceptionBusy.
@BlazeStudios & @HawaiianHopeOrg
I’m still exploring the queue and may eventually settle on that. The only hangup I have right now is that I don’t want the queue in place all the time, and if someone calls while there are people in the queue, I want them added to the queue, not to jump in line. I’m still working that part out with the options that are available.

What is the IVR ID? You can find it in the URL on top, for example http://IP/admin/config.php?display=ivr&action=edit&id=39 this would be ID 39.

@PitzKey
IVR ID is 15

[time-based-block]
exten => s,1,Noop(Check if we need to prevent ${CALLERID(all)} from reaching the queue)
 same => n,GotoIf($["${SHELL(/path/to/script.sh ${CALLERID(num)})}"="block"]?block)
 same => n,Return()
 same => n(block),Goto(ivr-15,s,1)

Set the Return in the Custom Destination to the original destination.
Assuming it was Inbound Route → Extension 123, set it to Inbound Route → Custom Destination → Return = Extension 123.

@PitzKey
OK. I am getting ready to implement. I see the 300 second expiration. Where can I change the number of tries before the call is routed to the IVR? Is that the [ “$value” -ge 5 ]instruction? If so, this script blocks after five attempts, right?

Can I set it to do the same if the callerid is blocked? Or is that handled the same way?

Can I put the script in a directory that is backed up with the system? Admittedly, I haven’t researched this at all, so if the answer is obvious, I apologize…

drnate

The ge 5 would determine whether the script echos block or continue. The 300 expiration is to control the period for how long to keep track of the data.

Currently it only blocks if he same caller ID calls more than 5 times within 5 minutes.

You can place it in whatever directory you want, alternatively, you can add your backup job the path to this script.

@PitzKey
Thank you for your help. I have made the recommended changes. In addition, I issued the following commands in my cli:

chmod + x busytimescript.sh
chown asterisk:asterisk busytimescript.sh

I also added a line to the end of the script so I could see if it is working (because it isn’t yet…)

Here is the updated script:

#!/bin/bash

phone_number=“$1”

if [ -z “$phone_number” ]; then
echo “Usage: $0 <phone_number>”
exit 1
fi

Increment the counter for the phone number

value=$(redis-cli INCR “$phone_number”)

Set/refresh expiration to 300 seconds

redis-cli EXPIRE “$phone_number” 300 >/dev/null

Check rate and print action

if [ “$value” -ge 3 ]; then
echo “block”
else
echo “continue”
fi

Uncomment the following to log and troubleshoot

echo “$phone_number” " " “$value” >> /home/asterisk/CustomScripts/busylog.txt

and here is the entire extensions_custom.conf from my GUI:
[from-internal-custom]
exten=> *00001,hint,DAHDI/1
exten=> *00002,hint,DAHDI/2
exten=> *00003,hint,DAHDI/3
exten=> *00004,hint,DAHDI/4

[time-based-block]
exten => s,1,Noop(Check if we need to prevent ${CALLERID(all)} from reaching the queue)
same => n,GotoIf($[“${SHELL(/home/asterisk/CustomScripts/busytimescript.sh ${CALLERID(num)})}”=“block”]?block)
same => n,Return()
same => n(block),Goto(ivr-15,s,1)

When I run the script from the command line it adds to my logfile.
When we receive a call, it does not.

My inbound routes are set to Custom Destinations: Created to redirect spam calls
My Custom Destination Target is: time-based-block,s,1
The Custom Destination returns to my time conditions (in this case, Special Closing).

We receive calls, I just can’t get the incrementer to work. Would you please check to see if I have done this correctly?

Thank you again for your help!

Can you please share a call trace via pastebin?

@PitzKey
Here is a trace of 1) a call from my cell phone (call # 60)and
2) a call from my cell phone w/ caller ID blocked (call #61)

Line 79 of the first call addresses the Custom Destination.

Do you know if we can delete pastebins? I accidently uploaded the wrong one…

Try this:

#!/bin/bash

phone_number="$1"

if [ -z "$phone_number" ]; then
    echo "Usage: $0 <phone_number>"
    exit 1
fi

# Increment the counter for the phone number
value=$(/usr/bin/redis-cli INCR "$phone_number")

# Set/refresh expiration to 300 seconds
/usr/bin/redis-cli EXPIRE "$phone_number" 300 >/dev/null

# Check rate and print action
if [ "$value" -ge 5 ]; then
    echo "block"
else
    echo "continue"
fi

# Uncomment the following to log and troubleshoot
echo “$phone_number” " " “$value” >> /home/asterisk/CustomScripts/busylog.txt

After the call, run redis-cli KEYS '*' and see if there is anything.

@PitzKey

Thank you again. I made the changes to the script and called several times in succession. My phone number is listed int the keys and the value (redis-cli GET “myphonenumber”) is incrementing properly. My logfile is not being populated (probably something I did wrong there).

The system still lets my call through, even after the value reaches 6 and 7.

After five minutes the key is deleted (expected and desired behavior).

I will put together another pastebin with the call trace in a bit.