Per my other post on this topic (Inbound screen pops using Twitter), I needed a way to be notified of inbound calls *before* I actually got them. The way I did this is to have inbound calls to my IBP number route to a Survo that then automatically forwared the call to my Virtual Receptionist. The Survo does a GET to my web page before it transfers the call. Inbound callers won't really notice any difference, but I had a minute before the call came in.
For this version, I made a few changes. First, I swapped out Twitter for GTalk. Twitter is great, but it was not always fast enough and there were many times when the service was just down (I should note that it has been pretty reliable for a while now).
Second, I wanted the IM to tell me WHO was calling (name & company). Finally, if I didn't already have them stored in the database I wanted it to send me a link to a simple HTML page where I could add the record. Now note - this is NOT the most elegant solution. Ideally, I would have a centralized contact database (i.e. Google or a CRM solution). But this was a quick and dirty implementation, so I just threw together a simple MySQL database.
-- So I have this set up so it will send an IM to different addresses based on a URL parameter. So you can point multiple inbound numbers to this code and it will send the IMs to the appropriate person.--
my_db_connect($database_host,$database_name,$database_username,$database_password) or die("can not open database");
$query="select contact, company, phonenum from contacts where " . "phonenum = " . $callerid;
$result = mysql_query($query) or die ("Cannot execute query : $query" . mysql_error()) ;
$row =mysql_fetch_assoc($result) ;
// creating a tiny URL to the page in case there is no record for that contact
$tiny = file_get_contents($teststring); $ch = curl_init(); $msg= "You have a call from " . $row['contact'] . " of " . $row['company']; if ($msg == "You have a call from of ") { $msg = "You have a call from caller ID: " . $callerid . ". You can add the record here: " . $tiny; }; -- Probably could be more efficient. But I'm setting the value of the IM text to be sent in the case where there is a record or is not a record for that Caller ID. --
--And that's it. Simple enough. Since my Virtual Receptionist plays a message before they transfer to me, I have a minute or two to bring up their records in our CRM before I even get the call.