Simple Inbound routing based on Caller ID - A Step by Step Guide

I wanted to do some specific call routing based on Caller ID, primarily to block Robo-calls.

The system needed to work as follows:

  1. Callers with no caller ID would be blocked ruthlessly.
  2. Callers with a “blacklisted” caller ID would be hung up on or sent directly to voicemail.
  3. Callers with a “whitelisted” Caller ID would ring through
  4. All other callers would be requested to enter a specific code in order to ring through.

I searched for a solution and settled on Asterisk as the fastest route to achieve my goal before the USA election season got into full swing this year.

While there was a lot of information, for the most part I found it to be either incomplete or too complicated, especially for an Asterisk neophyte such as myself.

I thought I would share what I have done so far in the hopes of giving other newbies a “jump-start” in using Asterisk in the home or small office.

My system is still in “alpha-testing” but this document is a very rough “step-by-step” guide that I threw together. Please feel free to comment, ask questions or make constructive suggestions.


Thanks for the module effort and every bit as importantly, the write up. I have not tried the module yet, but plan to shortly. I did not find any licensing information in the smarthomeroute tarball. Is there a development site set up for this project?

edit found the licensing info for SmartHomeRoute:
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

When I built the system in the lab I had it working the way I showed it built in the step-by-step guide. However, when I switched it over to live service, it quit working right. When the destination extension would ring, it would only ring about twice, then the system would hang up on it. The log would show that line had been picked up (which it hadn’t) and then disconnected almost instantly.

Hours of on-line research had no usable results. Either no information or too much information.

I pulled it back out of service and stewed on it while my real life intruded.

Then, after getting another Robo-call I was freshly energized to make it work. I had an flash of insight, remembering that one major difference between the production version and the test lab and was that in production there was an additional 600 feet of analog phone wire and two analog phones. I disconnected the long extension and viola! The system worked right!

The next step now was to add a script to allow a phone user to add callers to the white list. With my barely adequate understanding of dialplan coding and lots of trial-and-error modifications, using the “blacklist” code as a basis, I was able to get the script working.

I will update the guide to include the new script and post it.

I installed it throught the Freepbx interface.