1.1.3 • Published 10 years ago

notifuse v1.1.3

Weekly downloads
12
License
MIT
Repository
github
Last release
10 years ago

Node library for the Notifuse API

Notifuse connects all your notification channels (SenGrid, Mailgun, Twilio SMS, Slack, push...) to a powerful API/platform that handles templating, contacts segmentation and smart campaigns.

We recommend you to read the API Reference to understand the behavior and results of every methods.

Installation

npm install notifuse --save

Usage

var Notifuse = require('notifuse'),
    client = new Notifuse.Client(API_KEY, options);

Client options

KeyExpected value.
timeoutRequest timeout in ms. Default 5000.
maxAttemptsMax retry attempts. Default 5.
retryDelayDelay between retry attempts in ms. Default 250.
agentHttps agent for the requests.

Upsert contacts

// upsert an array of contacts

var myContact = {
  id: '123',
  profile: {
    $set: {
      firstName: 'John',
      lastName: 'Doe'
    }
  }  
};

client.contacts.upsert([myContact], function(error, result){
  if (error) {
   // handle error
  }

  // result example:
  // { 
  //   statusCode: 200,
  //   success: true,
  //   inserted: [],
  //   updated: ['123'],
  //   failed: []
  // }

});

// same with a promise

client.contacts.upsert([myContact]).then(function(result){

})
.catch(function(error){

});

Send messages

var Notifuse = require('notifuse'),
    client = new Notifuse.Client(API_KEY);

var myMessage = {
  notification: 'welcome',
  channel: 'sendgrid-acme',
  template: 'v1',
  contact: '123',
  contactProfile: {
    $set: {
      firstName: 'John',
      lastName: 'Doe'
    }
  },
  templateData: {
    _verificationToken: 'xxx'
  } 
};

client.messages.send([myMessage], function(error, result){
  if (error) {
   // handle error
  }

  // result example:
  // { 
  //   statusCode: 200,
  //   success: true,
  //   queued: [{ ... }],
  //   failed: []
  // }

});

// same with a promise

client.messages.send([myMessage]).then(function(result){

})
.catch(function(error){

});

Retrieve a message

var Notifuse = require('notifuse'),
    client = new Notifuse.Client(API_KEY);

var myMessageId = 'xxxxxxxxxxxxxxxx';

client.messages.info(myMessageId, function(error, result){
  if (error) {
   // handle error
  }

  // result is a message object defined in the API Reference
});

// same with a promise

client.messages.info([myMessage]).then(function(result){

})
.catch(function(error){

});

Support

Feel free to create a new Github issue if it concerns this library, otherwise use our contact form.

Copyright

Copyright © Notifuse, Inc. MIT License; see LICENSE for further details.