Giter Club home page Giter Club logo

node-messente's Introduction

messente

NPM version

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, but 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
};

var client = messente.createClient(opts);

// 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);
});

Account balance call.

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

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

Running tests

MSNTE_USER=<api user> MSNTE_PWD=<api password> MSNTE_SECURE=true MSNTE_NUMBERS="<comma separated list of numbers>" npm test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.