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

webtext-api

v0.0.3

Published

Send messages, check account balance, and manage contacts on WebText.com.

Downloads

6

Readme

Node.js WebText.com API Client

Send messages, check account balance, and manage contacts on WebText.com.

Installation

The following will install this package and add it as a dependency to your project:

npm install --save

Usage

Require this package after installing with npm:

var WebText = require('webtext-api');

Create a WebText object with your API User and Password:

var user = 'bw13cexH',
    password = '5yw8Vhc3';

var wt = new WebText(user, password);

Now you can call the various API methods.

Send an SMS message

See the Sending Messages section below for details.

wt.send({
    text: 'First message from WebText!',
    to: '353861234567'
}, function (err) {
    if (!err) console.log('Message sent successfully!');
});

Check account balance

wt.balance(function (err, balance) {
    if (!err) console.log('Account has ' + balance + ' credits');
});

Add a contact

wt.contacts.save('353861234567', {
    name: 'David Doran'
});

Add the contact to a group:

wt.contacts.save('353861234567', {
    group: '888392630'
});

Remove a contact

wt.contacts.remove('353861234567');

Just remove the contact from a group:

wt.contacts.remove('353861234567', {
    group: '888729566'
});

Add a contact group

wt.groups.save('Customers', function (err, group) {
    console.log('Group alias: ' + group);
});

Remove a contact group

wt.groups.remove('888729566');

Sending Messages

The following message will be delivered 20 minutes from now, to group 888392630, with sender '*Alerts*', with the id '12345', and receipts will be delivered to '[email protected]'.

var message = new WebText.Message({
    to: '888392630',
    from: '*Alerts*',
    text: 'This is an example SMS message',
    id: 12345,
    email: '[email protected]',
    delivery_delta: 20
});

wt.send(message);

Here is the full list of supported properties with examples:

Required: to is a phone number, array of phone numbers, or an array of group aliases.

{to: ['353863123456', '353863654321', '353861940728']}

Required: text is the text of the message.

{text: 'Thanks for subscribing to SMS alerts!'}

unicode is the unicode text of the message (either text or unicode must be given).

{unicode: 'Μιλάς Ελληνικά'}

tag (or from) is the name that will appear as the message sender.

{tag: 'Alerts System'}

id is a unique numeric id for the message.

{id: '201300001'}

url is the URL to which message receipts should be sent.

{url: 'https://example.com/webtext-receipts'}

email is the email address to which message receipts should be sent.

{email: '[email protected]'}

delivery_time is the date when the message should be sent, given by a Date object.

//Send the message on the 15th of January 2016
{delivery_time: new Date('2016-01-15 18:00:00')}

delivery_delta is the number of minutes to wait before sending the message.

//Send the message 10 minutes from now
{delivery_delta: 10}

validity is the number of minutes the SMS is valid for (after which delivery will not be attempted).

//Message is valid for 5 hours
{validity: 300}

License

This project is released under the MIT License.