Intelligently split SMS messages with sms-splitter

TLDR: sms-splitter is an npm package for splitting templated SMS messages into multiple sub-messages, for a much improved product experience. Get it here.

The Problem

At Promise, a part of our product suite involves sending SMS messages to people. These messages contain very important information, such as when their next court date is, and therefore ensuring that the messages do not in any way confuse people or cause them undue stress is very important to us as we strive to support them through a very challenging time.

SMS messages that use more than 160 characters are automatically divided into multiple messages and sent separately through the various mobile networks. This can result in a few bad scenarios:

  • Messages arrive out of order, causing confusion and stress, particularly if the messages to arrive first leads the reader the wrong conclusion
  • Messages are broken up at arbitrary positions, such as in the middle of an address, leading to it being difficult to use this information, e.g. copy/pasting the address into Google Maps. This can lead to people turning up to the wrong address, calling the wrong phone number etc. In the justice system, these technical violations can land you in jail.

The Solution

To solve this we wrote sms-splitter. It is a Node package that achieves a few seemingly simple but useful things.

  1. All strings are split on a space character. No word is ever split across two messages, unless a single word is longer than 160 characters.
  2. If Mustache string templates are used, e.g. Hello {{name}}, you have an appointment at {{address}} at {{time}}.` then the contents of each piece of data, such as name, address and time in this example, will never be spread across two messages, unless one of them is longer than 160 characters.
  3. Optional characters can be placed at the end of each text message to indicate that there are more messages to come, e.g. ...

See the examples for suggestions on how you can use it. The work remaining, which this does not solve for, is specific to each application that uses it. Once you have split a single message into multiple sub messages, each of these will have to be send individually to your provider, e.g Twilio, and their success/failure tracked in a grouped fashion, rather than receiving a single message ID and report from Twilio.

Each project will also be responsible for deciding how it sends these in order: at Promise we pre-split all messages and send them out with a multi-second delay between them, to make a best-effort attempt at having them appear in order. This is not guaranteed, but now that we have much more control over when the messages are sent, we can make it far more likely to arrive in order.


Please give us feedback on the project, ideally in the Issues on Github. We’d love to hear suggestions on future features, and bugs that you’ve found. Best of all, this is fully open source, so please also send pull requests with improvements and we’ll happily review them for inclusion.

Finally, we’re hiring! Come work with us to help massively reduce incarceration rates in the US by bringing empathy and world class technology to the justice system.