Friday, June 29, 2018

SMS over IRC

A couple years ago, I moved from Google Voice to custom infrastructure.  That system used XMPP to send SMS.  Now that I've moved from XMPP to IRC, I needed a new set up for sending SMS.  This post is about a small proxy I wrote to translate between SMS and IRC protocols.

When I'm connected to our family IRC server, I can send a message to any nick that's a valid phone number.  The server converts that message into an HTTP request to Twilio to send an SMS to that number.  I map our IRC nicks to our phone numbers to correctly set outgoing caller ID.

Some of my extended family (mom, dad, siblings, etc.) aren't connected to our IRC server.  I contact them frequently enough that I didn't want to use their phone numbers in IRC, so I've given them aliases.  The server pretends that they're on IRC under those aliases.  For instance, when I send a privmsg to the IRC nick "mom", it converts that into a Twilio API call that sends an SMS to my mom's phone number.  As far as my IRC clients are concerned, my mom is on IRC.

When sending SMS, Twilio provides helpful status updates via HTTP.  I've translated some of those into IRC messages too.  In an IRC client, it looks like this:

[12:01:02] michael: Any big plans for your birthday?
[12:01:03] mom: ⌛
[12:01:07] mom: ✓
[12:05:22] mom: I'm going to Cirque du Soleil with some friends


The first two emoji are synthetic messages generated by the IRC server.  ⌛ means, "Twilio has successfully delivered the message to the recipient's phone company" and ✓ means, "the phone company delivered the message to the recipient's phone".

Incoming SMS work as you'd expect.  The phone number to which the SMS was sent, determines which IRC user receives the corresponding privmsg.  If the phone number has an alias, that alias is used as the IRC nick; otherwise, the phone number is used as the nick.

It all works really well in practice.  I can pretty much pretend that everyone I care about is on IRC all the time.

Twilio doesn't support group SMS, which is too bad.  I'd love to translate those into ad-hoc IRC channels.  Twilio supports MMS, but I receive them so rarely that I haven't added IRC support yet.

The code is available, in case you're interested.  It's a couple hundred lines of Go.

No comments: