messente

Node.js client library for Messente group messaging platform

npm install messente
6 downloads in the last week
7 downloads in the last month

messente

Node.js client library (unofficial) for Messente (https://messente.com) group messaging platform, based on Messente API v2. For more information and how to use and setup Messente API, read Messente API documentation.

Setup

npm install messente

Usage

Although Messente API v2 doesn't seem to support multiple recipients per message anymore, there is a workaround. The message will be sent for every recipient separately.

var messente = require('messente');

// Create a new Messente API
var opts = {
  username: '<api-user>',
  password: '<api-secret>',
  secure: true
};

messente.createClient(opts, function(err, client) {
  if (err) {
    console.log('Error: ' + err.message);
    return;
  }

  // Compose message
  var message = {
    to: [ '+372500000000' ], // You can specify multiple recipients here
    text: 'Hello!'
  };

  client.sendMessage(message, function(err, result, ids) {
    /**
     * result: [ { error: null,
     *             code: 'b3258850cef53cd8b904a8185d6375c9f7d96369',
     *             phone: '+372500000000' } ]
     *
     *
     *  ids: [ 'b3258850cef53cd8b904a8185d6375c9f7d96369' ]
     *
     */

    if (err) {
      console.log('Error: ' + err.message);
      return;
    }

    console.log('Result: ');
    console.log(result);
  });
});

sendMessage callback will return an array of the delivered messages id's, which can be use to track delivery status.

client.getReport([ 'b3258850cef53cd8b904a8185d6375c9f7d96369' ], function(err, result) {
  /**
    * result: [ { error: null,
    *             code: 'DELIVERED',
    *             report: 'b3258850cef53cd8b904a8185d6375c9f7d96369' } ]
    */

  if (err) {
    console.log('Error: ' + err.message);
    return;
  }

  console.log('Result: ');
  console.log(result);
});

Additionally Messente account balance call is also supported.

client.getAccountBalance(function(err, result) {
  if (err) {
    console.log('Error: ' + err.message);
    return;
  }

  console.log('Result: ');
  console.log(result);
});
npm loves you