Asterisk Voicemail that reacts to my AIM status
It occured to me that my computer already “knows” whether I’m in the office or not because my iChat status (aka my AOL Instant Messenger/AIM status, as they use the same IM network) is automatically set to “Away” if I’m idle, and “Available” when I return.
As such, shouldn’t my voicemail be able to reflect this — i.e. not bother ringing my phone if I’m not in the office?
Here’s how I achieved this using Asterisk and an AGI script written in PHP.
First, I needed some code to grab my AIM status. The easiest way to do this is using cURL (note, you’ll have to have cURL compiled into your PHP; see this page on the PHP site for details).
I use cURL to connect to the URL that is otherwise used to display graphical “I’m online” messages on users’ websites; because I’m not actually displaying graphics, just grabbing the status, I can use the arbitrary strings ON and OFF:
$url = “http://big.oscar.aol.com/screenname?on_url=ON&off_url=OFF”; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, 4); $result = curl_exec($ch);
Executing this (substituting your actual AIM/iChat screen name for ‘screenname’) will result in the variable $result being set to either “ IMG SRC=ON” (with the leading space) or “ IMG SRC=OFF”. You can then react accordingly in the rest of your AGI script. For example:
if ($result == ” IMG SRC=ON”) {
print “EXEC Playback TryingPeterNow\n”;
print “EXEC Dial SIP/100\|20\n”;
print “EXEC Playback PeterIsNotHere\n”;
print “EXEC Voicemail 100\n”;
print “EXEC Hangup\n”;
}
else {
print “EXEC Playback PeterIsNotHere\n”;
print “EXEC Voicemail 100\n”;
print “EXEC Hangup\n”;
}
This code plays a message like “I’m trying Peter now” if my AIM status is “ON”, and rings my SIP extension, sending to voicemail if I don’t pick up in 20 seconds. I’ve my AIM status is “OFF,” then I say something like “Peter’s not here” and send directly to voicemail.

Comments
Post new comment