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
It is neat to see Primus
It is neat to see Primus offer a consumer’ized version of the cool stuff you have been doing (minus things such as AIM status integration)
http://www.primus.ca/en/reside…
Maybe so about Primus, but
Maybe so about Primus, but some people aren’t happy about it…
Check this out:
http://www.angustel.ca/update/…
By the way, great blog. I’m looking into Asterisk myself, looks really cool.
What happens if the aol
What happens if the aol server is down? With your current script it defaults to send ing directly to voicemail. I’d make the if statement test for “IMG SRC=OFF” before sending directly to vm, and otherwise always try the extension first.
I am right in the middle of
I am right in the middle of doing this same type of thing but with our internal Jabber server (jabberd2) that I just put up, and parking all information in MySql, which I figure I will then be able to have Asterisk query, and execture my logic based on the quiery results. Plus, added side effect, no interfacing whatsoever with those idiots at AOL. Have you read theie new privacy policy?! They are as evil As Rumsfeld. I digress. I figure that having it all in house lets us maintain the control over it & not be surpised when that one day comes that AIM decides to lock everyone out everyone who hasnt bought a new scanner off their site in the last 30 days.
(side note: if this notion of jabber gateways works out for us, users wont need any other IM’s other than Jabber, we can do all the heavy-lifting on the server to communicate with other IM’s.)
Thanks.
Cheers.
Peace.
Jason
Just wanted to comment on
Just wanted to comment on this great idea, and let you know that if you have a cell phone, as I do with BlueTooth, you can use a little program called BluePhoneElite http://www.reelintelligence.co… with a 30 day demo I think) to notice your proximity to your computer, so when you get within range, it will perform certain actions trough it’s own interface, or through any applescript you set. It has built in support for iChat Status, so now your phone will start ringing again as soon as you stem through the door of your office. :) Great…. heh hope it”s usefull for you.
Add new comment