![]() |
||
|
|
Version 0.7 Caller ID and Notification System for Asterisk Copyleft (C)2005 Nathan E. Pralle www.nathanpralle.com BASIC OPERATION
Several things are needed prior to making this system work:
INSTALLATION Installation is fairly straightforward. There are 3 main directories, 'agi', 'cgi', and 'bot'. Each of these contains files for each of the modules of HooDaHek. Other files are for various other things:
HOODAHEK_TABLE.SQL: This is a user and table definition for the 'hoodahek' user and table. The user is created with all privileges; yeah, I know that's not the best, but if your machine is local and firewalled, etc etc, you won't be fussed. The table is simple enough as well. To apply the whole file, modify as you like, then run: mysql -u root -p asteriskcdrdb <hoodahek_table.sql Give the root password and it'll run and return to the prompt. This assumes that your cdr_mysql table is named 'astersiskcdrdb' and not something like 'mypants'. Change as appropriate. HOODAHEK_DBHANDLE and HOODAHEK_NOTIFY: Open each file and look at the Configuration Options. Adjust as necessary. Place both of these files inside your Asterisk AGI directory, usually located in: /var/lib/asterisk/agi-bin/ You might want to check to make sure you have all the necessary Perl modules installed by using: perl -c /var/lib/asterisk/agi-bin/hoodahek_notify perl -c /var/lib/asterisk/agi-bin/hoodahek_dbhandle If you see errors, run for your life. Get the appropriate modules from CPAN (search.cpan.org). EXTENSIONS.CONF.EXAMPLE: This is an example extensions.conf. This is by NO MEANS COMPLETE! You'll have to add this functionality to your own extensions.conf file, usually located in /etc/asterisk/extensions.conf. Syntax for hoodahek_dbhandle: This script handles the database insertion for new callers. If all you want to do is keep track of who has called, this is all you really need. Syntax is CALLERIDNAME, CALLERIDNUM, UNIQUEID, as shown below: exten => _X.,2,agi,hoodahek_dbhandle|${CALLERIDNAME}|${CALLERIDNUM}|${UNIQUEID} Syntax for hoodahek_notify: This script handles the notification of an incoming call via AIM/MSN/Jabber. If you don't want this, don't add it to your extensions.conf. Syntax is CALLERIDNAME, CALLERIDNUM, phone they are calling. IE: If they're calling the landline, I put "landline". Or the IAX line is "VoIP Phone". Don't include quotes. exten => s,2,agi,hoodahek_notify|${CALLERIDNAME}|${CALLERIDNUM}|landline At this point, you can reload the Asterisk extensions and test it: asterisk -vvvvvvvvvvvvvvvvvvvvr > extensions reload Place an incoming call. You should see the AGI scripts run. If you don't, you didn't set it up right. Nothing else should happen, really. We haven't set up the notification bot yet. :) HOWEVER -- if you look in your 'hoodahek' table of the MySQL database, you should see an entry for the call. If not, check your setup. Easy way to look: mysqldump -u hoodahek -p asteriskcdrdb hoodahek Give the password and it'll dump the table contents. Good? Good. Quit out of the Asterisk CLI. HOODAHEKBOT.PL: Now it's time to setup the AIM/MSN/Jabber bot that will notify you of an incoming call. Make sure you have the right Perl modules installed: perl -c hoodahekbot.pl First, create the location where it will live: (as root) mkdir /usr/local/hoodahekbot mkdir /usr/local/hoodahekbot/queue chmod 777 /usr/local/hoodahekbot/queue Copy the files: cp hoodahekbot.pl /usr/local/hoodahekbot chmod 755 /usr/local/hoodahekbot/hoodahekbot.pl Open /usr/local/hoodahek/hoodahekbot.pl in your favorite text editor and modify anything underneath the Configuration Options that needs to be adjusted. Be sure to set the username and password (optionally: server) of your specified AIM/MSN/Jabber user correctly. You must "turn on" whichever bot(s) you want to use -- make sure to find those sections. Now, start it up: /usr/local/hoodahekbot/hoodahekbot.pl & Assuming you're logged into AIM/MSN/Jabber with a different username, and you have your bot in your buddy list, you should see them log on. Nifty. If not, and the process quits, find out why. (usually has to do with a directory permission or something similar) The bot logs ALL activity to /var/log/messages. I highly recommend you startup 'tail' to watch that file while you're playing with the bot, like so: tail -f /var/log/messages XWindows Users: Note that if you start this within an xterm/konsole/etc. window, you'll want to close the window by typing 'exit' and not clicking the X in the corner or it'll kill the process. :) Now make a phone call into your Asterisk box. Assuming you have your extensions.conf set up correctly, and the bot running correctly, you should get an IM from your bot saying who called. COMMANDS: HooDaHekBot responds to 4 different commands: 'name', 'phone', 'last', and 'quitnow'. It will ONLY respond to someone who is in its notify list -- IE: someone it sends notification of a call to. This is for security reasons, of course. The usage is as such:
HIRES TIMING: The bot can take up to 1 second after a call comes in to let you know who it is. You can significantly reduce this delay by activating HiRes timing. Install the Time::HiRes Perl module and then set $use_hires=1 inside hoodahekbot.pl. HOODAHEK.PL: CLID is pretty decent but not all names come through correctly, or the number does but not the name, or any number of screwups. Here's where the real power of the extra database comes in -- the ability to customize the CLID name. Copy hoodahek.pl to your cgi-bin directory on the same server. Load it up in a web browser. Assuming all is well with the world, you should see a listing of all entries in the 'hoodahek' table. If not, something's messed up. You can see that there is an update button to allow you to change the CLID name. Do so as you please. The next time you receive a call, you'll notice that both the CallerID of the call is changed and the CallerID displayed by hoodahek_notify is changed; it'll use that name instead of the default name provided by the telco. Groooovy. KNOWN ISSUES: 0 4 * * * killall hoodahekbot.pl 1 4 * * * cd /usr/local/hoodahek;./hoodahekbot.pl & Your mileage may vary on this one. QUESTIONS/SUPPORT/COMMENTS: Please feel free to use my Contact Page on my website to contact me if you have questions, ideas, concerns, etc. I'll try to help the best I can, but I can't promise everything. CONTRIBUTORS: The MSN code was taken/derived/bastardized from work by: William Kelley, Eric Hodges, Matt Austin, Siebe Tolsma, Talha Asad, Steve Fullbrook, and of course, the original MSN.pm writer and all others who made minor improvements. Your efforts saved my ass time and time again. Thank you every so much. The AIM/Jabber code was taken from many different sources around the 'net; thanks to those who went before me and figured out the dirty, sweaty bits first. You folks have way too much time on your hands. :) Thanks to Adam Bumpus for the inspiration and hints on how to do the SMS stuff. He wrote (and figured out) a very cool SMS mailing script to scan your inbox and text-message you every time you get a new mail. Isn't that the shit? Check it out here. Thanks to Steven BerkHolz for suggesting that I actually modify the CLID. Gee, now that was obvious. :) Thanks, Steven, for pointing out my dufusness. I hope you enjoy HooDaHek. I've had fun writing it. | |