Google Voice + Locale

By • Feb 19th, 2010 • Category: Android

About a month ago I purchased one of those awesome Nexus One Google phones and started tinkering to see what cool things I could make it do.  I love the phone, and as many of you know, absolutely love Google Voice too.

I figure the only way Google Voice could be improved is if it magically knew where I am and make my phones ring accordingly – so that’s exactly what I made it do.

You can too with an Android phone, the Locale app and a web server.

Goal:
Tell Google Voice which phones to ring based on your current location or situation.

Requirements:

  • Google Voice
  • Android phone w/ internet and GPS
  • Locale for Android ($9.99, QR code)
  • Locale GPS Plug-In (Free, QR code)
  • HTTP Poster and Locale Plug-In (Free, QR code)
  • Web server w/ PHP 5 (uses cURL and json_decode)

Part 1 – The PHP:

  1. Download googlevoice-locale.php
  2. Add your Google Voice login and password to the top and save
  3. Upload the script to a secret location on your web server

Part 2 – Configure Locale:

  1. Create a new Situation with a condition of where or when your Google Voice settings should change (ie: while you’re sleeping, at home or in the office)
  2. Add a Setting using the HTTP Post plugin to tell your server which phones to turn off or on

    HTTP Post settings:
    URL – http://yourawesomeserver.com/googlevoice-locale.php?on[]=home&off[]=work
    Select GET
    Save

  3. Name, save and activate the Situation

The PHP script is set to toggle numbers using the names you assigned them on the Google Voice settings page, so if your phone is named “Work” use “work” (lowercase) in the URL.

The possibilities with Google Voice and Locale are endless. In addition to toggling phones based on your location, you can toggle them when you’re with your mistress, when your phone is charging or about to die, and can even route your calls through Gizmo when you’re connected to your home WiFi.

My favorite trick is to forward all calls to my wife by turning my phone face down.

Let me know in the comments if you need help or think of other useful situations for Locale and Google Voice.  Enjoy.

Tagged as: , , ,


Email this author | All posts by

35 Responses »

  1. I’m growing impatient for the N1 to arrive on VZW’s network. This would be perfect for me… the ability to send my calls automatically where I need them based on a much more loose schedule than what I can setup in the actual GV interface.

    Kudos again, sir.

  2. Dude,

    very nice tutorial, as usual!

  3. Awesome, I’ve been wanting this functionality for the last half-year or so. Thank you for sharing this.

    BTW, there is another software package called “Tasker” which is still in beta, but should be able to work the same way (and if it doesn’t the author will quickly fix the http function). It also has an “application” condition which would allow you to turn off your mobile number when you start a SIP client, or the forthcoming Verizon/Skype app.

  4. This is fabulous. I do have one concern. Do you think it is a security risk having your google username and password stored on the web in plain text? Is there anyway to encrypt that data!?

  5. Hi Tommy,

    The file is plain-text on my server so it can be downloaded. Once you save it on your server you will need to rename it to some-file-name.php.

    This will make it so there is no output when you visit the URL. There is no risk having your username and password in there as long as no one else has access to the source on your server. It is no different than having your database username and password in your wordpress config.

  6. Yo John… It’s called the Droid, and OMGZ, it has a KEYBOARD!

  7. Thanks Chad, I appreciate the feedback.

  8. Hello Chad,

    I am the Developer of the HTTP Poster Plug-In. This is exactly the kind of stuff i imagined when writing that plug-in.

    That is the best use of it I saw so far.

    Thanks for sharing,

    Toby
    Steelgirder Development

  9. This is awesome! Thank you so much for developing and sharing this.

    Reading this motivated me to find some sort of solution for the iPhone. I ended up using my Google Latitude location and comparing that to my phone locations, calling your script whenever the Latitude to phone distances changed. A daemon on my phone updates my Latitude position (jailbreak app name: Longitude) and a cron job on my server runs every 5 mins to keep everything relatively up to date. So far, works like a charge.

    Great work!

  10. I’m having an issue getting this to work, and I’m not sure if it’s related to this line:

    ‘source’=>’chadsmith-googlevoice-locale’));

    I wouldn’t think that everyone in the world should use that particular setting; I tried substituting my own Google username in there, but no joy. I’m not seeing any errors when I invoke the PHP page (either with my guesses at a source name, or with the one you listed), but it’s also not making changes to my phone settings…

  11. Bruce,

    What kind of error are you getting? That line is required by Google to tell them the application you’re using to log in. Read more about it here.

  12. Thanks for the URL – that was the page I was trying to find, but failed for some reason. I’ll work it out on my own now… :)

  13. I didn’t have a Grand Central account; I started with Google Voice. I wonder if that’s where it’s falling down?

  14. Try changing the lines activate($phones[$phone]); and activate($phones[$phone],false); to var_dump(activate($phones[$phone])); and var_dump(activate($phones[$phone],false)); to see the output.

  15. Feel free to delete all these posts of mine… it seems to be working now. Just more of a delay than I was expecting to see the changes appear in the UI. Sorry for all the “noise”

  16. FWIW, just re-clicking the “Settings” link in the Voice UI was not enough to have it update the “Phones” tabe info. I had to switch away from Settings completely (like to my Inbox) and then come back into Settings in order to see the changes. When I do that, it’s almost an instant update…

  17. I would also love to be able to enable disable call presentation with this script. So for instance, when I am at home, the phone rings, my wife answers and hears, “call from…” she knows to hand the phone to me before answering. Love this BTW!!!

  18. @JPWG3

    Great idea! You can change any of the settings using PHP and Locale so that’s definitely doable.

    Add:

    if(isset($_GET['direct'])){
    $direct=intval($_GET['direct']);
    googleapi('https://www.google.com/voice/settings/editGeneralSettings/?auth='.$auth,array(
    'directConnect'=>$direct,
    '_rnr_se'=>$rnr
    ));
    }

    Just before:

    // hooray done!

    And then add &direct=0 to the URL to enable call presentation or &direct=1 to disable it.

  19. I’m not able to find the Locale GPS Plugin, at least not by that name. I scanned the QR and got just the generic listing of all things Locale in the Android Market.

    Is this bad?

  20. Followup to my own question:

    From Carter at Locale….

    “Hi,

    Thanks for your interest in Locale!

    Those instructions are incorrect: the GPS Plug-in is not needed at all. It does not help Locale determine your location in any way.

    Please let me know if I can help you further!

    Thanks and have a great day,
    Carter”

  21. That leads me to believe the guys at Locale don’t know their own product. I just emailed you instructions on how to find it. I don’t believe you can set conditions based on your location without it.

    If all else fails, try Google Voice Locations

  22. That was awesome! Thanks for the code to toggle call presentation.

    Out of curiosity where did you find the documentation of the GV api?

  23. There is no Google Voice API, but I’ve documented some of my methods here.

  24. Is anyone else having an issue wherein GV has stopped responding to this php file?

  25. noah, can you say more about your methods? I’d love to do this on my iphone, should be pretty easy now with background location apps, like latitudie.

    I’m wondering how you are comparing your latitude and phone locations?

    Thanks, this script is fantastic.

  26. Many thanks for this. I currently use a VoIP provider that allows API access to toggle on/off DND during nap times. Turning a phone off and using the calling groups will allow me to do this, but still allow some people the ability to call through while DND is on! In cases where I want to shut everyone off, I’ve added what is needed to toggle DND.

    if(isset($_GET['dnd'])){
    $dndexpire = “-1″;
    $dnd=intval($_GET['dnd']);
    googleapi(‘https://www.google.com/voice/settings/editGeneralSettings/?auth=’.$auth,array(‘doNotDisturb’=>$dnd,’doNotDisturbExpiration’=>$dndexpire,’_rnr_se’=>$rnr));
    }

  27. As a follow up, this php file doesn’t seem to interact with google voice for me either. :(

  28. FYI, this still works for me with no issues, however, if your account has the Google Multiple Sessions feature enabled, this will NOT work. I’m assuming there is some backend work that needs to change with regards to URL’s in order for this to work.

  29. Actually, just go through and change all URL’s (accept the ClientLogin URL) and add “/b/0/” after the “/voice” section in the URL’s. That should make this work with the Multiple Sessions feature enabled on the account.

  30. Thank you Bubba for that fix!

  31. Is there a way to use the php script to toggle between a number of different voicemail greetings depending on where you are or the time of day?

  32. This looks awesome. Thanks!
    Is there a way to have the script on the server do a time check to see when the last update was sent from Locale/Tasker, and if it’s been more than, say, 5 minutes, revert to a preset setting?

    I’m often in areas where I don’t have data access on my phone, (or maybe my plan just sucks), and I’d love to have it automatically switch from GV sending calls to my Skype number to sending them directly to my phone in that situation, but without data on the phone, the phone itself can’t change GV settings.

Trackbacks

  1. [...] originally wrote up his instructions at his own site, where you can find his other projects and hobbies, like a Google Voice add-on for [...]

  2. [...] home WiFi. My favorite trick is to forward all calls to my wife by turning my phone face down. Google Voice + Locale at That Smith __________________ [...]

  3. [...] home WiFi. My favorite trick is to forward all calls to my wife by turning my phone face down. Google Voice + Locale at That Smith __________________ [...]

Leave a Reply