Smart & Dumber

I needed some peaceful, distraction-free time this month.

To that end, I edited my hosts file to filter out unwanted sites. I deleted social media apps and enabled parental restrictions on my phone. I even created a small Safari extension to block access to certain sites unless I accessed them via a Google search (I don’t need to drink from the MetaFilter distraction firehose, but it’s still helpful to filter results to site:ask.metafilter.com when searching for recipes and date night suggestions).

It still wasn’t enough, so I decided to downgrade upgrade to a lovely flip phone. Amusingly, it’s actually my first! (Before the iPhone days, I had a non-flippy Nokia 8210, and I loved it dearly.) It cost me $14.99 on Amazon.

Flippin' it.

One big problem. My dinky new phone knows nothing of iMessage! I don’t need to respond all that quickly to most people I text with, but my girlfriend does not always appreciate it when I walk away from my desk in the middle of a conversation. (“But — Wendy! Darling! Light of my life! I consider texting to be an asynchronous form of communication!” Good luck with that one, fella.) To make matters worse, she has to pay per text on her work phone. So, what’s to be done?

The answer: using Google Voice and my inbox as a bridge, I’ll use AppleScript to sling my SMS messages over to iMessage, and to extract my girlfriend’s replies.

This project assumes that you’re an iCloud user with access to a Mac running Mavericks, and that you have access to Google Voice. Note that this solution only lets you bridge your SMS/iMessages with one of your buddies. I’m sure the scripts could easily be adapted for multiple contacts, but that’s not what I needed to accomplish here.

Step 1: set up Google Voice.

Choose a Google Voice phone number, and enable SMS-to-email. This lives under Settings > Voicemail & Text > Text Forwarding.

Once you’ve been assigned a number, send a text to it from your cell! When it arrives, take note of the custom email address Google sends it from. It will look something like this:

1[GV #].1[SENDER #].[HASH]@txt.voice.google.com

Step 2: sling your SMS messages to the Messages app.

Sender Screenshot

Open the “iMessage Slingshot Sender” script in AppleScript Editor. You’ll need to change two things here:

send theBody to buddy "718-555-1212"
of service "E:you@icloud.com"

“718–555–1212” should be replaced by the phone number of your spouse, loved one, compatriot, buddy, or other most important iMessage contact. “you@icloud.com” should be replaced by your iCloud email address. (Make sure to retain the “E:” prefix.)

Now save your script, and move it somewhere Mail can find it! That’d be ~/Library/Application Scripts/com.apple.mail/.

You’ll need to create a new rule in Mail to trigger the script every time you an SMS that you’ve sent from your cell lands in your inbox. Mail rules live in Mail > Preferences > Rules. Click “Add Rule.” Give it a fancy name, and set the following as your only condition: From is equal to 1[GV #].1[SENDER #].[HASH]@txt.voice.google.com. Under “Perform the following actions,” select “Run AppleScript” from the first drop-down, then select your script from the second drop-down. Save the script, but don’t apply it to your entire inbox when prompted. Oh, and, before you leave the Preferences window, you might also want to make sure that mail is being checked regularly.

Now test it out! Send an SMS to your GV number from your cell. It should open the Messages app and send that SMS to your loved one as an iMessage.

Now, we just need to slingshot their replies…

Step 3: …slingshot their replies.

Receiver Screenshot

Open the “iMessage Slingshot Receiver” script in AppleScript Editor. This script is triggered whenever anyone sends you a message in Messages. If the sender is your loved one (your very patient loved one, who doesn’t question your need to use a dumb phone for a couple of days until you finally come to your senses), it extracts their iMessage, plunks it down into an email sent to that same txt.voice.google.com address, and sends it.

You’ll need to change two things here, too:

if theHandle = "+17185551212" then
set recipientAddress to
"1[GV #].1[SENDER #].HASH@txt.voice.google.com"

“+17185551212” should be replaced by your lover’s phone number. The txt.voice.google.com number should be replaced by that email address GV generated for you.

Note that there’s a lot of cruft in that script. In Mavericks, the Messages app has lost its event handling GUI. Instead, every single script needs to define every possible event or AppleScript will throw an error. Sorry about that. Just ignore it. You might also notice that “on active chat message received” is defined separately. I’d recommend ignoring it, or your texts might come through twice. (And if the receiver script is suppressed because you’re actively using Messages? Not a big tragedy.) Again — sorry.

Now, save your script. This one needs to live in ~/Library/Application Scripts/com.apple.iChat/. To activate your script, head over to Messages > Preferences > General. At the bottom of that pane, select your script from the “AppleScript handler” dropdown.

Congrats! You’re done! Your SMS messages will be routed to your inbox through GV, then slung (slinged? slang!) to your favorite iMessage user. The interstitial email will be summarily trashed. Then their iMessage replies will be emailed back to GV via your Mail app. The best part is, a complete record of your conversation will exist in both iMessage and GV!

Just keep in mind that you should add your GV number to your phone’s contacts. You’ll be texting to that number, not your iMessage buddy’s number.

You can grab the two scripts via github. Please let me know how they work out for you.

Now, to master T9