Search code examples
vonage

Why do I get message-count = 3 from nexmo send SMS callback?


I send SMS using Node.js like this:

const Nexmo = require('nexmo');

const nexmo = new Nexmo({
    apiKey: process.env.NEXMO_API_KEY,
    apiSecret: process.env.NEXMO_API_SECRET
});

const opts = {
    'type': 'unicode'
};

function sendSMS(to, content) {

    nexmo.message.sendSms('qwe, to, content, opts, (err, data) => {
        if (err) return console.error(err);
        console.log('Data: ', data);
    })
}

After in callback data, I'm getting the response like this:

  {
   "message-count":"3",
   "messages":[
      {
         "to":"380967547714",
         "message-id":"0C000000E412D0DB",
         "status":"0",
         "remaining-balance":"238.91280000",
         "message-price":"0.07300000",
         "network":"25503"
      },
      {
         "to":"380967547714",
         "message-id":"0C000000E412D0DC",
         "status":"0",
         "remaining-balance":"238.91280000",
         "message-price":"0.07300000",
         "network":"25503"
      },
      {
         "to":"380967547714",
         "message-id":"0C000000E412D0DD",
         "status":"0",
         "remaining-balance":"238.91280000",
         "message-price":"0.07300000",
         "network":"25503"
      }
   ]
}

I've got the reasonable question: why do I get "message-count": 3? It turns out that I get 3 webhook. Is it should work like this?


Solution

  • I can see that you are sending Unicode messages. Maximum length allowed for Unicode content is 70 characters, whilst "normal" text messages will allow up to 160 characters.

    When a single SMS body exceeds 70 characters, the SMS will be split into multiple parts and then will be reconstructed at the handset level.

    That is why you are getting multiple webhook calls for the sent message.

    If you were to send messages as "normal" text SMS and not Unicode type, you'd have 160 characters for a single SMS.