Development

Control Your Budget With SMS Preview

A method that gives you a chance to see how your SMS message will look like before you decide to send it.

March 22 2017

There are hundreds of tutorials that will help you implement the SMS functionality into your business processes, help you reach a wider audience or nurture existing users. That said, you might think you’re ready to start sending promotional or informative messages to your clients.

Still, there are things you need to be on the lookout for, even with a provider that makes sending an SMS easy as 1,2,3. Sending an SMS message seems simple enough, until you hit an unexpected roadblock. Just one unsupported character can significantly reduce the total number of characters per message, which can cause a message to be split into two or more messages and significantly increase the cost of your SMS campaign. Things get even trickier when messages must be sent in different languages and language and transliteration options are introduced.

These are just some of the actions that can hurt your budget, all of which can be avoided by using SMS preview before sending the actual SMS, and with no additional costs.

By showing you the message length, the number of message parts, language and transliteration output, you can optimize the number of characters in your SMS message and stay inside your expected budget.

This is where the SMS preview method comes in handy. It provides the following info:

  • originalText represents the original text of the previewed message
  • textPreview represents a preview of the text as it should appear on the recipient's device
  • messageCount is a number of messages required to deliver the textPreview
  • charactersRemaining is the number of remaining characters before the messageCount increase
  • configuration represents configuration setup that should be included in advanced SMS in order to deliver 'textPreview' message

Start counting messages and remaining characters

Using the POST method allows you to see how many characters are left 'unspent' in the message and if the message fits in one or more messages.

JSON request:


POST /sms/1/preview HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json

{
    "text": "Let's see how many characters will remain unused in this message."
}

JSON response:


{
  "originalText": "Let's see how many characters will remain unused in this message.",
  "previews": [
    {
      "textPreview": "Let's see how many characters will remain unused in this message.",
      "messageCount": 1,
      "charactersRemaining": 95,
      "configuration": {}
    }
  ]
}

When you receive the response, it will contain the original text (sent text) and the preview, which showcases the message received by the recipient without any configuration. In this case, the text fits into one message and there are 95 more characters to spare. Note that if you want to send an SMS message as you see it in the 'textPreview' there is no need for further configuration.

You can use 'simple' or 'advanced' 'send SMS' methods to send this message.

So, this part was easy. With no additional setups, you’ll be able to see the number of messages and the number of remaining characters in the message. But, the problem occurs when you run a global business and you need to deliver the same message to your global user base, but in a different language. Unlike English, certain languages use a ‘special character alphabet’. To learn more about this, check out our National Language Identifier page.

Adjust the message language

Your business has the option of creating and sending long messages, but this can increase costs of your messaging campaigns. The National Language Identifier (NLI) offered by Infobip is an encoding technology that allows an SMS, which contains language-specific characters usually treated as 16-bit Unicode, to be delivered as original text, while deducting only 5 characters from the maximum SMS length. This way you get 155 characters instead of the usual 70 characters if using Unicode.

By relying on our encoding method, you can save money on the number of characters and stay inside the budget while sending messages worldwide.

JSON request:


POST /sms/1/preview HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json

{
    "text": "Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.",
    "languageCode": "TR"
}

JSON response:


{
  "originalText": "Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.",
  "previews": [
    {
      "textPreview": "Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.",
      "messageCount": 2,
      "charactersRemaining": 36,
      "configuration": {}
    },
    {
      "textPreview": "Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.",
      "messageCount": 1,
      "charactersRemaining": 57,
      "configuration": {
        "language": {
          "languageCode": "TR"
        }
      }
    }
  ]
}

This time you’ll notice that there are some differences. Now, the response model has the 'originalText' and two previews. The first preview shows a scenario in which no configuration has been applied. The second one shows a scenario with the language configuration applied.

As you can see in the first preview, characters are interpreted as Unicode, which uses 2 message parts and brings the remaining number of characters to 36. The second preview option shows results with language settings. The messages look the same except the number of remaining characters and the total number of messages that will be sent.

In this specific case, you would want to use the 'languageCode' configuration to instruct the system to use the correct (GSM) alphabet. By performing this you’ll decrease the number of characters spent in a message.

The preview method shows exactly which configuration settings to use when sending an advanced message and gives you the ability to send a much longer message:


"language": {
    "languageCode": "TR"
 }

Give transliteration a try

Since there is a limited number of languages supported by NLI, the other option for saving on the number of remaining characters is transliteration - a method of replacing unsupported characters by similar or related ones, that are part of the default alphabet. And, since transliteration is a technique that replaces original special characters, having an output message preview makes a lot of sense.

Let's take a look at the example of an SMS in Greek and with the transliteration option:

JSON request:


POST /sms/1/preview HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json

{
    "text": "Ως Μεγαρικό ψήφισμα είναι γνωστή η απόφαση της Εκκλησίας του δήμου των Αθηναίων (πιθανόν γύρω στο 433/2 π.Χ.) να επιβάλει αυστηρό και καθολικό εμπάργκο στα",
    "transliteration": "GREEK"
}

JSON response:


{
  "originalText": "Ως Μεγαρικό ψήφισμα είναι γνωστή η απόφαση της Εκκλησίας του δήμου των Αθηναίων (πιθανόν γύρω στο 433/2 π.Χ.) να επιβάλει αυστηρό και καθολικό εμπάργκο στα",
  "previews": [
    {
      "textPreview": "Ως Μεγαρικό ψήφισμα είναι γνωστή η απόφαση της Εκκλησίας του δήμου των Αθηναίων (πιθανόν γύρω στο 433/2 π.Χ.) να επιβάλει αυστηρό και καθολικό εμπάργκο στα",
      "messageCount": 3,
      "charactersRemaining": 46,
      "configuration": {}
    },
    {
      "textPreview": "ΩΣ MEΓAPIKO ΨHΦIΣMA EINAI ΓNΩΣTH H AΠOΦAΣH THΣ EKKΛHΣIAΣ TOY ΔHMOY TΩN AΘHNAIΩN (ΠIΘANON ΓYPΩ ΣTO 433/2 Π.X.) NA EΠIBAΛEI AYΣTHPO KAI KAΘOΛIKO EMΠAPΓKO ΣTA",
      "messageCount": 1,
      "charactersRemaining": 5,
      "configuration": {
        "transliteration": "GREEK"
      }
    }
  ]
}

The response model would be formatted in the original text with two previews, a scenario in which no configuration is applied and a scenario with the desired transliteration configuration applied.

This example shows you how the unsupported characters were replaced with similar characters which are included in the default alphabet. Comparing it with the 'messageCount', the default message would cost 3 messages per recipient, while transliteration brings the message count to 1, with 5 characters remaining.

But let’s get back to the beginning of this story – your budget. Using the SMS preview will help you stay inside your budget and keep your SMS campaigns running as planned.

*Still, even though the preview engine relies on the same business logic as the actual message sending, we cannot guarantee that the message received by the recipient will look exactly like the message in the preview, since some networks may not support the language feature or handle it differently.

Start using SMS preview

Visit our developer hub