UPDATE: As some of you may know, all of the Google Voice apps are now gone from the App Store (GV Mobile is on Cydia now), however this method still works as it does not rely on anything but Prowl on the iPhone side of things.
This solution makes use of Prowl, Python, some python libraries, and a desktop or server machine of some kind to act as the intermediary between Google Voice and Prowl’s API, so you will need to have some command line experience, and a machine available to run this software on.
You will of course need a Google Voice account, without which most of this article will be just an interesting read for you. They are free, but available by invitation only. Google appears to be rapidly sending out invitations to those who apply and may be pushing the service into the public very soon, but you can apply for an invite here.
You will also need the Prowl application for the iPhone, which costs $2.99 in the App Store, however it is the only iPhone App i am aware of that allows arbitrary push notifications to be sent using a published API, so it is an essential component to this setup, and an all around cool App to have.
If you do not have one of the native Google Voice iPhone apps, you do not technically need one to receive notifications, but they make it much easier to interact with the Google Voice service from your iPhone. I have been testing GV Mobile by Sean Kovacs and am quite happy with it so far.
So with your Google Voice account information in hand, and the Prowl application installed and working (you don’t actually need the prowl plugin here), lets go ahead and install the scripts needed to get this all working. I will be doing the tests on Ubuntu 9.04, but this should work equally well on any machine with a Python installation, including Mac OS X, Windows, and any of the BSDs.
You will need to make a directory somewhere on your machine, i called mine prowl-gv in my home directory. This is where all of the custom scripts and files will go, including your Google Voice account password, so make it someplace permanent and safe.
The scripts used here were written by multiple individuals. First, the Prowl python interface was written by Jacob Burch and the code is available on github here. You will need to download the prowlpy.py file and put it in your prowl-gv directory. If you copy and paste the code, be sure to keep the indentations intact as Python depends on them, simply copy/pasting from the web interface on github into a text editor may not work.
Second, the interface between Prowl and Google Voice was written by Mike Krieger, and is available on his github account here. Download those files and stick them in your prowl-gv directory as well, again being careful for indentations if you copy/paste the code.
And now on to the dependencies as needed on Ubuntu:
steve@server:~/prowl-gv$ sudo apt-get install python-beautifulsoup python-simplejson python-httplib2
UPDATE:Some users have asked how to install these things on OS X. The answer is to use MacPorts and install the following packages:
py-simplejson
py-beautifulsoup
py-httplib2
Once you have the dependencies worked out, you will need to make some text files in your prowl-gv directory. The first should be called prowlkey, and it should contain the API key for your Prowl account. You can get this by going to the prowl website, log in, and go to the settings page. Here you can generate the key and copy it into the correct file on your local machine.
The second file should be called credentials, in it you should put your Google Voice credentials, in the form of user password (just a space between them).
You will want to change the permissions for these 2 sensitive files such that they are only readable by your user account, the one you intend to run the scripts under. One could potentially be used to spam your phone using Prowl, the other could compromise your entire Google account, so chmod each of them to 600 to deny all access to everyone else on the machine:
steve@server:~/prowl-gv$ chmod 600 prowlkey credentials steve@server:~/prowl-gv$ ls -l total 32 -rw------- 1 steve steve 28 2009-07-25 09:10 credentials -rw-r--r-- 1 steve steve 3670 2009-07-16 04:44 googlevoicenotify.py -rw-r--r-- 1 steve steve 853 2009-07-16 04:44 prowlgooglevoice.py -rw------- 1 steve steve 41 2009-07-25 09:10 prowlkey -rw-r--r-- 1 steve steve 1877 2009-07-20 17:16 prowlpy.py
With all that done, you can test things by running python prowlgooglevoice.py. If it works, you will see this:
<blockquote> steve@server:~/prowl-gv$ python prowlgooglevoice.py checking done checking, will sleep for 60 seconds
When Google Voice gets an SMS, a line will show up in the console, and your iPhone should get a push message. To give you an idea of what it currently looks like……
Currently, the Google Voice scripting will only retrieve SMS messages, however Google Voice users can already choose to get e-mail notifications of voice mails. The scripts appear to be in development, so in the future they may do voice mail notification as well. One feature that would be nice, would be for the SMS number to be resolved to a Google contact name, assuming we know the person and have entered a contact for them.
If you only wish to run the script as-is, in a terminal, no further work is required. If you wish to background the script or have it run on every reboot, you will need to check on how to do this for your specific operating system. On Ubuntu, running the script with a trailing & will background it (but it may not keep running if you close the terminal), and a simple cron job would allow you to run the script at every reboot, or a more complicated init script could be used (or for the truly geeky, an upstart job).
UPDATE: For those of you who wish to simply let your crontab execute the command every so often, i have modified the prowlgooglevoice.py script to be a “run once” sort of thing so cron does the looping, rather than let the python script loop itself:
<blockquote>
from googlevoicenotify import GoogleVoiceNotify
from time import sleep
import sys
from os.path import join
class ProwlListener:
def __init__(self):
PROWL_API_KEY = file(join (sys.path[0], 'prowlkey'), 'r').read().strip()
import prowlpy
self.prowl = prowlpy.Prowl(PROWL_API_KEY)
def on_notification(self, event, from_name, message):
self.prowl.add('Google Voice %s' % event,from_name, message)
class PrintListener:
def on_notification(self, event, name, message):
print "%s: %s said %s" % (event, name, message)
if __name__ == '__main__':
prowl_listener = ProwlListener()
print_listener = PrintListener()
name, passwd = file(join (sys.path[0], 'credentials'), "r").read().split()
gv = GoogleVoiceNotify(name, passwd, listeners=(prowl_listener, print_listener))
gv.check()
Basically i modified the file checks in python so that they work regardless of the current working directory (which is different for cron), then stripped out the while loop to allow the script to run gv.check() once and then exit. Once you have that done, you can add a line in your crontab (run crontab -e to edit) that looks like this, replacing the path with the real path to your scripts:
<blockquote> # m h dom mon dow command */1 * * * * "python /home/steve/prowl-gv/prowlgooglevoice.py"
This will cause your script to run every minute, check google voice for messages and then exit. You can insert any number of minutes you like in the cron job, the default for the script was every 60 seconds, but if you want it to check every 5 minutes, replace the 1 with a 5.

Hi there!
Thanks for the writeup, and glad you’re enjoying the googlevoicenotify Python script.
One quick note is that running it using Python (as the script is written at the moment) will cause you to reauthenticate with Google every time. I’ll add a feature in the next version to save your cookies locally so you can run it in cron and not have to have the script re-auth to Google every time.
Mike
Oops, too early in the morning to comment on a thread :)
What I meant was running it in Cron this way will re-auth with Google; running it normally in Python will save your cookies. In the future, running it with Cron should also save your cookies.
Also, the new version up at github.com/mikeyk/googlevoicenotify/ adds the ability to have the script ask you for your username/password interactively, rather than needing a credentials file.
Cheers,
Mike
Thanks for the update :)
thanks for putting together these great instructions! unfortunately, i can’t seem to get this script to run on my linux-based shared server hosted at godaddy.com. i keep getting a 500 internal server error message. in particular, i can’t figure out how to install the packages needed for these scripts onto the server itself. any ideas? Thanks!
If you are on a shared host you may not be allowed to install packages, but you should contact the host and ask them if they can install those scripts for you.
I am receiving the following message when running the script:
Could not load ProwlListener…exiting.
You have new mail in /var/mail/xxx
Why won’t the listener start.
crontab -l displays:
# m h dom mon dow command
*/1 * * * * “python /Users/xxx/python-gv/prowlgooglevoice.py”
Any help is greatly appreciated.
Make sure you have all the correct scripts in the directory, it may not be loading the classes or functions from the other prowl script(s)
Any plans on porting this to app engine? That way no server would be required, and we can even have a cron run every minute …
i’ve been encountering some issues with defaultdict and pickling in python 2.4. i’ve come across a fix for the defaultdict, but do you know how to get around the following error? i’m running a virtual-python environment because i’m trying to run the script on a godaddy shared hosting server. it works, but only once and then throws the following:
-bash-3.2$ ~/bin/python ~/html/cgi/prowlgooglevoice.py
sleeping…
Traceback (most recent call last):
File “/var/chroot/home/content/…/html/cgi/prowlgooglevoice.py”, line 66, in ?
gv.check()
File “/home/content/…/html/cgi/googlevoicenotify.py”, line 173, in check
pickle.dump(self.convo_threads, out_fl)
cPickle.PicklingError: Can’t pickle : attribute lookup googlevoicenotify.defaultdict failed
also, i was hoping to use your version of prowlgooglevoice.py in order to use it in the crontab, but that’s not working either. it looks like mikeyk has done some updating to his script. any chance you could modify your version as well?
thanks for the help!
It is my understanding that App Engine is restricted to running code called by a remote request and not periodically like we’re doing here, however i have seen references to “cron” like functionality and background jobs in some documentation and forums, so maybe :)
According to the Google App Engine documentation there is now a cron feature. I am working on porting this to App Engine, however it appears there is no current stable way to interface with Google Voice, all of the python modules i have found for retrieving messages from the service have broken repeatedly when Google changes things.
Porting the existing python modules (googlevoicenotify, pygooglevoice) to app engine is not hard, but in my tests today none of them appear to work even as standalone scripts because of changes google has made since they were written.
Leave a comment or question