npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parrot-messenger

v1.0.13

Published

<a href="https://www.blackstone.studio/" target="_blank"><img src="https://blackstone-open-assets.s3-us-west-2.amazonaws.com/header.png" alt="Blackstone Studio - In Development We Trust"></a>

Downloads

196

Readme

Parrot Messenger

Table of Contents

Features

Parrot Messenger is a messaging library that can normalize the APIs for different messaging transports. In its current iteration it supports 3 types of transport classes:

  • Email
  • SMS
  • Call

Email Services

  • AWS SES
  • Mailchimp (Mandrill)
  • Mailgun
  • Sendgrid
  • SMTP

SMS Services

  • Twilio
  • Mailjet

Call Services

  • Twilio

Installing

Using npm:

$ npm install parrot-messenger

Using bower:

$ bower install parrot-messenger

Using yarn:

$ yarn add parrot-messenger

Initialization

Parrot needs to be initialized with the transports that it will be using before being used.

// ES6
import Parrot from 'parrot-messenger';

// CommonJS
const { Parrot } = require('parrot-messenger');

const parrot = new Parrot({
  transports: [
    // List of transports settings enabled
    mailgun,
    mailchimp,
    ses,
    sendgrid,
    mailjetEmail,
    mailjetSMS,
    twilioSMS,
    twilioCall,
    smtp,
  ],
});

The parrot instance receives an array of transports with the settings for each transport. Each transport will have slightly different settings, particularly around the authentication for each. Example configurations are available in the examples.js file.

Settings

Each transport has a defaults object where you can define default parameters for all messages generated by that transport. So for example you can define a default from value for every message.

This is a sample object for AWS SES transport along with its default values:

const ses = {
  name: 'ses',
  settings: {
    auth: {
      region: '',
      credentials: {
        secretAccessKey: '',
        accessKeyId: '',
      },
    },
    defaults: {
      from: '[email protected]',
    },
  },
};

API

Parrot Messenger works with a simple send service and a templating, here we'll describe the usage for the send method. The send method receives 2 parameters, both being objects. The first parameter is the parameters for the object that we want to send and the second one is the settings for the transport we want to use.

Example API call:

const email = {
  to: '[email protected]',
  subject: 'Sample Message',
  html: 'Hey Joe, nice talking to you!'
};

const transport = { 
  class: 'email', 
  name: 'ses'
};

parrot.send(email, transport);

Templates

We can also use and register templates when using Parrot Messenger, so we can pre-define a set of messages we will be using. We use a templating language (Handlebars) to replace values inside the template before being sent.

Example Template Registration & Usage

// Register a template, notice the ussage of {{name}}
// this value will be replaced
parrot.templates.register({
  name: 'Sample Template',
  html: '<p>Hey there {{name}}!!</p>',
});

const messageData = {
  to: '[email protected]',
  subject: 'Hey there!',
};

const transport = {
  class: 'email', 
  name: 'ses'
};

// Send an email using this template
parrot.templates.send(
  'Sample Template',
  messageData,
  // Sample Data for Template
  { name: 'User' },
  // Transport Settings
  // Available classes email, sms & call
  // Available transports per Class:
  // Email: 'ses', 'mailgun', 'mailjetEmail', 'mailchimp', 'smtp'
  // SMS: 'twilioSMS', 'mailjetSMS'
  // Call: 'twilioCall'
  transport
);

Async Templates

If you need to get the HTML template from an API service prior to senting a template you can do this as well. Parrot Messenger will use Axios to make an API request and fetch the necessary data, and it can be mapped from the response.

Example Async Template

// Register template
parrot.templates.register({
  name: 'Async Template',
  // Request is a standard Axios type object
  // with an additional resolve parameter
  // that resolves the response of the object
  // API reference for Axios:
  // https://github.com/axios/axios#axios-api
  request: {
    method: 'GET',
    url: 'https://reqres.in/api/unknown/2',
    data: {},
    headers: {},
    // Path to string we want to use in the request's response
    resolve: 'support.text',
  },
});


const messageData = {
  to: '[email protected]',
  subject: 'Hey there!',
};

const transport = {
  class: 'email',
  name: 'ses'
};

// Send an email using this template
parrot.templates.send(
  'Async Template',
  messageData,
  // Sample Data for Template
  { name: 'User' },
  // Transport Settings
  transport
);

Who are we

We are the development partner of choice for several different sized companies who need a team that delivers fast & scalable code understanding users needs and commercial scope.

Our services

  • Website development
  • UX/UI Design
  • Webapp Development
  • Mobile Development
  • Ecommerce
  • Specialized enterprise software
  • Legacy migrations, debugging and refactors

Why us?

We don't outsource a single thing. Each wireframe, design and every piece of code is written with outmost care by Blackstone's diverse teams.

🛠 Built With

🤝 Contributing

Contributions, issues and feature requests are welcome!

You can also suggest a new feature by creating an Issue. Please wait for confirmation before working on it.

📝 License

Copyright © 2020 Blackstone Studio.

This project is MIT licensed.