Asterisk and Australian Reverse Caller ID Lookup

It’s been a while since my original script to use for Australian caller ID lookups and since the online database disappeared, my script went into the archives.

Now its back.

Thanks to the API functions offered by Reverse Australia we can now have caller ID lookups back in Asterisk!

You’ll need a few things to achieve this:
1) Obviously a Linux PC running Asterisk
2) Asterisk::AGI Perl module
3) LWP::UserAgent perl module (should be included with your distro)
4) A running MySQL Database
5) My cid-lookup-v4.agi script.

Setup the MySQL Database with a table called ‘cid’ and two fields called ‘name’ & ‘number’. We use this to store unidentified inbound callers as well as cache looked up details from Reverse Australia. This means you can go edit the details later and have them show as you want rather than as unknown or the content returned from Reverse Australia.

Setup is VERY basic. Throw cid-lookup-v4.agi into your agi-bin directory, then place AGI(cid-lookup.agi) in your extensions.conf where you process incoming calls.

You will need to edit the script and change the setup for your MySQL database – as well as add the Reverse Australia API key.

Looking up calls online is optional.

This has been tested with the following configurations:
CentOS 5.5 with perl-LWP-UserAgent-Determined from rpmforge.
Fedora 14 with stock F14 perl-LWP-UserAgent-Determined package.

If you use CentOS, it is much easier to use the prebuilt perl packages from rpmforge. If you use CentOS, save yourself the heartache and use rpmforge for perl modules!


1 ping

Skip to comment form

  1. Nice work Steve, clean code 🙂 Out of curiosity, is there a reason you chose not to use the spam threshold parameter? We have around 3,200 otherwise unlisted numbers in our database that will only show up as being telemarketers when a spam threshold set as we have no other contact information to identify them.

    Oh, I just noticed. ‘$sth->execute($number, $number);’ for unknown caller doesn’t set a name.

    If you have any ideas for data we can offer, or how we offer it with the API I’d be very interested in hearing them.

  2. Thanks James,

    I haven’t used the spam threshold as I couldn’t see enough data on how it worked to see if I wanted to use it. I understand it works on complaint numbers – but complaints to who? ie who says what is spam and what isn’t? ACMA? Complaints to Reverse Australia?

    You are also correct on setting the number twice. I add all incoming numbers – even if unknown. This way a user can go in later and manually change the name field to something known. I use the same database to generate a phonebook listing for a Cisco VoIP phone – this script ignores entries where name == number.

    Some more information on any info you gather would be nice – also as I mentioned above on how the calls are classified as spam and by who and what methods. This would be a good thing 🙂

  3. Ah, totally makes sense why you didn’t use it. I’ll update the docs later with a full explanation.

    Basically until our own feedback loop is in place, we’re collecting complaints we’ve found on other sites that focus on the problem, along with their complaint date.

    We have an algorithm which basically tries to determine how spammy the number is based on the the regularity of complaints. If it has a lot of recent complaints the score will be high, or if the complaints haven’t shown up for a year or so the score might be low.

    As a rule of thumb, a score of 40 means either a lot of recent complaints or a lot of long term complaints. Anything over 50 would require both a lot of long term complaints and some recent complaints.

    You could also use the Spam API to come up with your own scoring system based on the given stats.

    We should have a feedback API up soon which will let people respond back telling us things like who they thought called, was it a spammy call, or whatever else they would like. All feedback will be moderated before being allowed to affect our spam stats. It would also be useful as it would allow people to share unlisted numbers with other PBX systems.

    Hope that helps

    • Tim on January 4, 2011 at 12:31 pm
    • Reply

    Why use an sql database? Why not just use a DBM tied to a hash? Its faster and has far lower overhead.

  4. I use the database with other scripts as well that are not on the same machine. I use the same data set with PHP, and this script. SQL is easier for this. Eventually, I’ll get around to getting the PHP stuff up to scratch and releasing that too.

  5. I have a more detailed installation procedure on my Wiki if people are interested.

    Thanks again Steven for this excellent script. It has allowed me to remove my ASTdb and many lines in my dialplan.

  6. Hey may I use some of the material from this site if I link back to you?

    1. Sure. Its there to help the community…

  1. […] love to see developers finding interesting ways to use our API.Steve over at created a really neat script for Asterisk using our Developer […]

Leave a Reply

Your email address will not be published.