How to Delete More than 10 Google Voice Messages at a Time


2013-06-22

NOTE: While this module works to place Google Voice messages in your trash, it does not currently delete messages from the trash. Apparently, calling delete() on a message in your trash will place that message back where it was deleted from (!), so we're kind of back into the not actually being able to delete messages.

While it's very easy to save a lot of money with Google Voice, Google, in their infinite wisdom, has made it near impossible to delete a large amount of Google Voice messages at time. The Google Voice web interface only allows deleting of 10 messages at once. So you have to select all on the page (10 of them) then click delete. To make it even worse, they are merely sent to your trash folder, which also limits "Delete Forever" to 10 messages at a time. And it makes you confirm it with an alert window! Wow... I understand why they would rather you not delete the messages (see the sidenote below if you're curious), but I will reserve my right to bulk delete until they make it impossible. So here is how you can delete a ton of Google Voice messages with very little effort. This can include SMS, placed calls, received calls, missed calls and voicemail -- essentially all of the different folders in Google Voice.

There are a few things you will need. You can likely replace a few of theses (OS?), but it will make it harder for anyone that doesn't have programming experience. It's not that straightforward to begin with. Here's the requirements:

  1. Ubuntu (preferably 12.04)
  2. python-setuptools
  3. simplejson
  4. mercurial
  5. root user permissions on your machine
  6. A python package called PyGoogleVoice

There are some more on the way, and I'll try to walk you through getting the above set up. But if you're already lost, it might be best for you to sit this one out -- just for the sake of saving you wasted time. Here are the commands to install what we need. If you have them already, then running these commands won't do or hurt anything:

sudo apt-get install python-setuptools mercurial
sudo easy_install simplejson

Now, we can clone the PyGoogleVoice repository and install the package:

hg clone https://pygooglevoice.googlecode.com/hg/ pygv
cd pygv
sudo python setup.py install

This package hasn't been worked on since around 2009, I believe, so I had to make some changes to it's core utils. There are forks of it out there, but I didn't realize that until I had hacked on it myself. The first change is to alter the login url the package uses to access Google Voice. To do this, you need to open a terminal and type:

sudo gedit /usr/local/lib/python2.7/dist-packages/googlevoice/settings.py

Then changing the LOGIN variable on line 22 to this:

LOGIN = 'https://accounts.google.com/ServiceLogin?service=grandcentral'

Now we have to disable some hash checking that caused the package to fail for me:

sudo gedit /usr/local/lib/python2.7/dist-packages/googlevoice/util.py

Then comment out line 181 (A # is a comment in python):

def __init__(self, folder, id, data):
    #assert is_sha1(id), 'Message id not a SHA1 hash'

You'll need to do the same in the voice.py file:

sudo gedit /usr/local/lib/python2.7/dist-packages/googlevoice/voice.py

And comment out line 241:

    for msg in msgs:
        if isinstance(msg, Message):
            msg = msg.id
        #assert is_sha1(msg), 'Message id not a SHA1 hash'
        data += (('messages',msg),)

Writing your own Python script to delete Google Voice messages

Now that we have "repaired" the package itself, it's time to write a script that uses it. Create a file named delete.py in your home directory (~/) and put this in it:

from googlevoice import Voice

voice = Voice()
voice.login('GOOGLEUSER', 'PASSWORD')

while voice.sms().messages:
    for message in voice.sms().messages:
        message.delete()

while voice.trash().messages:
    for message in voice.trash().messages:
        message.delete()

You will need to replace GOOGLEUSER and PASSWORD with your username and password for your Google Voice account. Once you save that, you can run it using this command to delete all of your SMS messages:

python delete.py

It will also delete them from your trash, so that they are completely deleted. You can alter the middle bit of the script to delete other Google Voice folders:

For placed calls:

while voice.placed().messages:
        for message in voice.placed().messages:
            message.delete()

For received calls:

while voice.received().messages:
        for message in voice.received().messages:
            message.delete()

Notice that I'm just changing the function in the two lines there (from sms() to placed() to received()). Other available folders/functions are:

missed()
voicemail()

Side note on why Google would like to keep you from deleting your messages:

Google makes most of their money via advertisements, at this point. For an ad to be successful, it needs to be clicked on and then the person clicking on it needs to generally take action and purchase a good or service from the company that paid Google to show the person the ad. To decide which ad would be most successful when shown to you, Google has systems that read any content you give to them. This content includes Google Voice messages, so Google would rather you keep all of your messages in Google Voice forever. This is so they can read your messages and decide if it's more beneficial to show you the advertisement about the lawyer or the one about the all-natural hot dogs.