Fragment an outbound SMS

    When sending a message, Voxbone will forward the message you specify with the most efficient encoding possible. However, the SMS protocol can only support a certain number of characters per message depending on the charset. Below is a list of the limited characters per message depending for each charset.

    Charset No Fragmentation 8bit frag_ref (frag_ref < 255) 16bit frag_ref (frag_ref > 255)
    7-Bit GSM 160 153 152
    Latin-1 140 134 133
    UCS2 70 65 64

     

    If you want to send a long message that contains more characters than what your charset allows, you have 2 options:

    1. You fragment the message before sending it to Voxbone, or
    2. Voxbone can do the fragmentation for you and send a concatenated SMS: auto-fragmentation.

     

    How to Fragment an Outbound Message

    If your message needs to be fragmented, you can send multiple messages and specify they are fragments of the same message. Voxbone will then deliver those to the same phone number you specified with the appropriate order of parts. The following explains how fragmentation can be achieved for sending messages.

    When sending a fragmented message using the VoxSMS API, you should follow the following steps:

    1. Check how long your original message is.
    2. Know which charset you are using (7-Bit GSM, Latin-1, UCS2)
    3. Know whether your frag-ref is bigger (16bit) or smaller (8bit) than 255
    4. Refer to the charset table above for encodings to know what the character limit is and how many segments you need to create.

    For example, if you want to send:

    Hello dolly, it’s so nice to have you back where you belong. You’re lookin’ swell, Dolly. I can tell, Dolly, you’re still glowin’, you’re still crowin’, you’re still goin’ strong.

    This is a string of 180 characters written in 7-Bit GSM. Let’s say it has a frag_ref of ‘1051’.
    This means that (looking at the table above) fragmenting this message will give a maximum of 154 characters per fragment. We can therefore send a fragment of 154 characters and one of 26.

    Fragment 1:

    Hello dolly, it’s so nice to have you back where you belong. You’re lookin’ swell, Dolly. I can tell, Dolly, you’re still glowin’, you’re still crowin’,

    Fragment 2:

    you’re still goin’ strong.

     

    Sample request

    The two requests sent will look like:

    Fragment 1:

    {
    “from” : “+14151111111”,
    “msg” : “Hello dolly, it’s so nice to have you back where you belong. You’re lookin’ swell, Dolly. I can tell, Dolly, you’re still glowin’ , you’re still crowin’, “,
    “frag” : {
    “frag_ref”: “1051”,
    “frag_total”: “2”,
    “frag_num”: “1”
    },
    “delivery_report” : “none”
    }


     Fragment 2:

    {
    “from” : “+14151111111”,
    “msg” : “you’re still goin’ strong.”,
    “frag” : {
    “frag_ref”: “1051”,
    “frag_total”: “2”,
    “frag_num”: “2”
    },
    “delivery_report” : “none”
    }

     

    Javascript Example

    //Fragment your message – assuming you are using UTF-8 and will be understood as 7-Bit GSM and your frag_ref is bigger than 255. This means each fragment will be 154 characters max.
    //Create an array of fragments
    var fragments = [];
    //Create a logic to add each fragment to the array if message is longer than maximum characters allowed.
    var maxchar = 154;
    if (message.length > maxchar){
    while (message.length > maxchar){
    fragments.push(message.substring(0,maxchar));
    message = message.substring(maxchar);
    if (message.length < maxchar){
    fragments.push(message);
    }
    }
    }else{
    fragments.push(message);
    }

    Auto-fragmentation

    If you want to send a long message that contains more characters than what your charset allows, Voxbone can do the fragmentation for you so you don’t have to handle it yourself – no more headache managing the SMS length.

    In this case, Voxbone will fragment your long message and forward the concatenated SMS over multiple SMS parts that are linked by the fragmentation information in the User Data Header (UDH).

    Thanks to this, when the handset will receive all the fragments of the long SMS, it will concatenate them and show them as a single text to the end user. You will be charged for each SMS sent as part of the concatenated message.

    The following will explain how the auto-fragmentation works.

    For example, if you want to send the following message:

    Hello dolly, it’s so nice to have you back where you belong. You’re lookin’ swell, Dolly. I can tell, Dolly, you’re still glowin’, you’re still crowin’, you’re still goin’ strong.

    This is a string of 180 characters written in 7-Bit GSM. So it will be fragmented in 2 transactions.

    In order to demonstrate the functionality, below is an example of a long SMS request with different possible outcomes.

    Sample request

    POST /sms/v1/32470209213 HTTP/1.1

    Host: sms.voxbone.com

    Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

    Content-Type: application/json

    {

      "from" : "+32466900002",

      "msg" : " Hello dolly, it’s so nice to have you back where you belong. You’re lookin’ swell, Dolly. I can tell, Dolly, you’re still glowin’, you’re still crowin’, you’re still goin’ strong.",

    }

    Sample response

    Based on the outcome of the fragmentation and submission process, 2 UUIDs will be generated:

    HTTP/1.1 202 Accepted

    Content-Type: application/json

    {

        "fragmented": true,

        "transaction_id": [

            "61b5db088d5b448e84a2a499008e6c5f",

            "94aed3bef444456191ef69181ab741e6"

        ]

    }