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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-sms-sender

v0.4.0

Published

Simple SMS sender to multiple recipients using Twilio

Readme

Simple SMS Sender

Library to send SMS messages to multiple recipients using Twilio API.

install size Typescript Known Vulnerabilities

Installation

yarn add simple-sms-sender

or

npm install --save simple-sms-sender

Usage

import { SmsSender } from 'simple-sms-sender';

const sender = new SmsSender({
    accountSid: '', // string, required
    fromNumber: '', // string, required
    logger, // Logger instance, optional, defaults to console
    secret: '', // string, required
    sid: '' // string, required
});

// Returns a promise
sender.sendSms({
    body: '', // string
    recipients: [], // array of strings
    scheduledTime: '' // optional ISO 8601 date string
});

sender.sendMultipleSms([
    { body: '', recipients: [] },
    { body: '', recipients: [], scheduledTime: '' }
]);

Example

import { SmsSender } from 'simple-sms-sender';
import pino from 'pino';

const logger = pino();

const config = {
    accountSid: '{Your Twilio Account SID}',
    fromNumber: '{Phone number to send}',
    secret: '{Your Twilio Secret}',
    sid: '{Your Twilio SID}'
};

const createSender = () => {
    const { accountSid, fromNumber, secret, sid } = config;

    return new SmsSender({
        accountSid,
        fromNumber,
        logger, // optional
        secret,
        sid
    });
};

const smsSender = createSender();

smsSender.sendMultipleSms([
    {
        body: 'Some message',
        recipients: ['+19999999999', '+18888888888']
    },
    {
        body: 'Some other message',
        recipients: ['+19999999999']
    },
    {
        body: 'Scheduled message',
        recipients: ['+19999999999'],
        scheduledTime: '2024-12-25T10:00:00Z' // Send on Christmas at 10 AM UTC
    }
]);

Features

  • Integration with Twilio API for SMS sending.
  • Batch SMS sending to multiple recipients.
  • Message scheduling - Schedule SMS messages up to 7 days in advance.
  • Customizable logging with support for external logger instances.
  • TypeScript support for type safety.

Prerequisites

Before using this library, ensure you have:

  • A Twilio account.
  • Twilio Account SID, Auth Token (Secret), and SID.
  • A phone number registered with Twilio for sending SMS.

API

SmsSender constructor

| Parameter | Type | Required | Description | | ---------- | ------------- | -------- | ------------------------------------ | | accountSid | string | Yes | Twilio Account SID | | fromNumber | string | Yes | Phone number to send from | | logger | GenericLogger | No | Logger instance, defaults to console | | secret | string | Yes | Twilio Auth Token (Secret) | | sid | string | Yes | Twilio SID |

Methods

sendSms({ body, recipients, scheduledTime })

  • body: string (required) — Message text
  • recipients: string[] (required) — List of phone numbers
  • scheduledTime: string (optional) — ISO 8601 formatted date/time to schedule message delivery (up to 7 days in advance)
  • Returns: Promise<any[]>

sendMultipleSms(messages)

  • messages: Array<{ body: string, recipients: string[], scheduledTime?: string }>
  • Returns: Promise<any[]>

Message Scheduling

You can schedule SMS messages to be sent at a future time using the scheduledTime parameter:

// Schedule a message for 1 hour from now
const futureTime = new Date(Date.now() + 60 * 60 * 1000);
smsSender.sendSms({
    body: 'This message will be sent in 1 hour',
    recipients: ['+19999999999'],
    scheduledTime: futureTime.toISOString()
});

// Schedule a message for a specific date/time
smsSender.sendSms({
    body: 'Happy New Year!',
    recipients: ['+19999999999'],
    scheduledTime: '2024-01-01T00:00:00Z'
});

Scheduling Rules:

  • Time must be in ISO 8601 format (e.g., 2024-01-01T12:00:00Z)
  • Time must be in the future
  • Maximum scheduling window is 7 days in advance
  • Invalid formats or times will throw validation errors

Logger

  • The logger parameter is optional. If not provided, logs will use console.log and console.error.
  • Logger must implement { info: (...args) => void, error: (...args) => void }.

Error Handling

Example

smsSender.sendSms({
    body: 'Hello!',
    recipients: ['+19999999999']
}).catch(error => {
    console.error('Failed to send SMS:', error);
});

smsSender.sendMultipleSms([
    { body: 'Message 1', recipients: ['+19999999999'] },
    { body: 'Message 2', recipients: ['+18888888888'] }
]).catch(error => {
    console.error('Failed to send multiple SMS:', error);
});

Additional Resources

Testing

To run tests:

yarn test

Release Management

Release versions follow Semantic Versioning.

To release a new version, ensure all tests pass and lint the code, then, make and push an empty commit like:

git commit --allow-empty -m "chore: release {release}" -m "Release-As: {release}"
# For example:
git commit --allow-empty -m "chore: release 0.3.0" -m "Release-As: 0.3.0"

Release Please will automatically detect the commit message and create a new release based on the Release-As tag.

Code Style & Linting

See CODE_STYLE.md for code style guidelines.

To lint the code:

yarn lint

Security

See SECURITY.md for security policy and how to report vulnerabilities.

Contributing

Contributions are welcome! Please open issues or pull requests.

Changelog

See CHANGELOG.md for release history.

License

This project is licensed under the MIT License. See the LICENSE file for details.