This is the fourth part of the Chatterbox series. For your convenience you can find other parts in the table of contents in Part 1 – Origins
Apart from web, desktop, and mobile you may want to have other channels.
Why would you need text messages for your service at all? Can’t you just turn on mobile data? Well, there are many reasons why texts are better:
- Mobile data doesn’t work everywhere — imagine hiking or just going to the woods
- Mobile data may be expensive — what if you’re travelling internationally?
- It consumes battery much faster
- You may just want to turn it off
While it may sound surprising, I’m actually using texts a lot to communicate. That’s partly because I travel often but also because I just don’t like having mobile data turned on all the time.
How to send
Now the question is, how to reliably send text messages. Let me start with this one statement — texts do get lost. Often.
If you’re just looking for “notification” text, not necessarily text where you must control the content, you can go with one time passwords from services like LinkedIn, GitHub etc. Just emulate logging in and the service will send you OTP as text. You won’t know what’s exactly happening, but you’ll have the notification (so you can turn your mobile data on).
If you need to send messages with controlled content, Google Voice sounds like a good option. You can send text via email. Similarly, multiple service providers offer email to text feature, you just mail some specific address and a text is delivered.
There are also some other platforms for mass texting etc. They typically charge for messages.
What to send
We mentioned encryption last time. You probably want to go with Base64 (or even better with Base58) for encrypted content. Keep in mind some countries may ban texting “encoded” messages.
Also, Base64 will make your messages much longer (regular text is allowed to be 160 chars long). While some platforms let you send one big message which will be assembled back on the mobile phone, I find it unreliable. I’ve seen to many broken messages due to that. Just go with assembling on your side, split messages into chunks and send them separately. This will probably lead to some form of packetizing with message numbering etc.
Keep in mind some characters may get replaced over the air. For instance, one number I was texting to was getting § (paragraph sign) instead of _ (underscore). On some other network I was receiving spaces instead of underscores. Go with Base58, this will give you four additional letters/numbers characters which you can use to encode signaling information.
How to receive
Once you start encrypting and packetizing your texts, you need to have a proper app on your phone. I don’t know how hard it is with iOS but for Android there are at least couple open source apps.
I was using QKSMS and I don’t think I recommend it. First, MMS messages do not work on my phone (actually here is a big warning — check your regular app if it handles MMS properly when you have data turned off and dual SIM, it is apparently super hard to implement). Second, code quality is slightly less than ideal so it may be hard to plug in your extensions.
I can recommend Silence. It’s a fork of Signal and while it has less features than QKSMS, its code quality is much better IMO and it works well with MMS (just had to go with some specific branch).
How to reply
You can go with sms to email feature. Use Google Voice (it has it built in), or ask your service provider. You may be for instance texting yourself (sic!) and then your application will be reading emails.
Things around security, encryption, packetizing etc — they are probably the same. You may want to enhance your text messaging app to split one contact into multiple (as you’ll be effectively chatting with one number all the times which will multiplex many contacts from various networks).
Sending and receiving is basically the same as for texts. You need to handle encryption etc.
Your service may either register for push notifications or just poll via IMAP each minute. This seems to be working fine for me.
Again, you may want to go with some service which just calls you and passes OTP (if you just want to get “notification”). You may also go with things like IFTTT if you want to control the message content. You may want to translate it beforehand to English, for that you may go with some free service like Yandex.
On a plane
This all works nice but what if you are on a plane and the only connection you have is some “chat only” wifi allowing you to use Whatsapp or Facebook?
You can mulitplex messages the same way. Just have another number which will be sending messages to you and which you’ll reply the same way as with texts.
Notes on decrypting messages
I mentioned that you can modify some open source applications but you can actually go with some other approach. Just prepare a simple HTML file with inlined JS for decrypting and depacketizing. When you receive a message, just copy it to the page on your phone and read over there. It’ll probably be much less convenient but also way easier to do than modifying some closed source app.