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

puretext

v0.1.5

Published

Use PureText.us API to send and receive texts

Downloads

30

Readme

Synopsis

So you have learned Node.js and you want to do something out of the ordinary by allowing your app to communicate with users real time. You could build an app for an event promoter that sends texts every Friday/Saturday evening promoting an event and even handle text responses or you could just build an app that texts every friend of yours once a week to stay in touch.

To send a text programmatically your code needs to make an XHR request to an SMS gateway that will read the text details from your request and then initiate a text to the recipient’s phone number

PureText offers a Texting/SMS gateway to which you can make an HTTP GET/POST request with details such as recipient number and body of the text and PureText will deliver the text to the recipient for you.

In order to identify that this request belongs to you, you’ll need to include your API token in the HTTP GET/POST request. Register for a free API token here

A thing to note is that you cannot just use any phone number as the ‘From’ number. The rule of thumb is the number must be registered through the same company who’s SMS gateway you choose to use.

To send a text message using Node.js you don’t need a dedicated short code. Dedicated short codes are expensive and take 2-3 months to get approved, instead, you can now use local 10 digit VOIP numbers or also referred to as long codes to send a  text/SMS programmatically from your Node.js app

So let’s get started, to do a quick and dirty POC you’ll need:

  1. An API token key (Get an API token here)
  2. A ‘From’ number through your SMS gateway (Get a from number here)

Copy Paste the following code in your IDE and replace the API Token and From Number values from the ones in your dashboar

Code Example


var puretext = require('puretext');

var text = {
  fromNumber: '+1XXXXXXXXXX', // From number is the number you will buy from your admin dashboard
  toNumber: '+1XXXXXXXXXX', // To Number is the number you will be sending the text to
  smsBody: 'Sending SMS using Node.js', // Text Content
  apiToken: 'XXXXXX' //Sign up for an account to get an API Token
};

puretext.send(text, function (err, response) {
  if (err) {
    console.log('there was an error',err)
  }
  else {
    console.log('there was no error',response)
  }
})

Motivation

Even though PureText uses a simple get request. Many users are using different modules to achieve an HTTP get like 'request' or 'superagent' or even native node.js http.request module. This provides a standard

Installation

npm install puretext --save

License

MIT