Display SMS segment count when constructing a Mass SMS
Overview
SMS messages over 160 characters in length are split into 153 character segments. If you use non-GSM characters (eg. ideograms, curly quotes, etc.) those messages are sent in UCS-2 encoding which limits segments to 67 characters.
SMS providers (Clickatel, Twilio, Nexmo, etc.) charge per segment.
I propose a modification to the New Mass SMS wizard to display the number of SMS segments required to send a Mass SMS on the SMS Content step of the New Mass SMS wizard. It will give users better visibility of the cost of their desired message.
Example use-case
- Click on Mailings -> New Mass SMS.
- Step through the first step of the wizard (Select Recipients).
- On the SMS Content step, as the SMS message is typed in, the number of segments required is displayed and dynamically updated alongside the display of the number of characters entered.
Current behaviour
As a SMS message is entered Civi displays the number of characters used. There is no indication of the number of message segments.
Proposed behaviour
Modify the maxCharInfoDisplay function in CRM/Contact/Form/Task/SMSCommon.tpl that dynamically displays the number of characters entered to also calculate and display how many segments are required.
The simplest approach might be to adopt this code (thanks StackOverflow):
gsm = "@£$¥èéùìòÇØøÅåΔ_ΦΓΛΩΠΨΣΘΞ^{}\[~]|€ÆæßÉ!\"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà"; var letter = 'a'; var letterInAlfabet = gsm.indexOf(letter) !== -1;
We could also consider adding a help icon to trigger a modal that provides some basic information about SMS segments, "weird" characters, etc. too.
Comments
The mockup I've attached is a good example of how a message that looks like it fits within a single segment can produce unexpected outcomes. The use of curly quotes push 148 characters across three segments, tripling the cost per recipient.
This happens relatively frequently as people often copy/paste content from Outlook, Gmail, Word, etc., documents/messages.