simple-sms-sender
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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({
  accountId: '', // string
  fromNumber: '', // string
  logger, // Logger instance, optional, defaults to console.log and console.error
  secret: '', // string
  sid: '', // string
});

// Returns a promise
sender.sendSms({
  body: '', // string
  recipients: [] // array of strings
})

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 sendSms = ({ body, recipients }) => {
  const {
      accountSid, fromNumber, secret, sid,
  } = config;

  const smsSender = new SmsSender({
    accountSid,
    fromNumber,
    logger,
    secret,
    sid,
  });

  return smsSender.sendSms({
      body,
      recipients,
  });
};

Promise.all([
  sendSms({
    body: 'Some message',
    recipients: ['+19999999999', '+18888888888']
  }),
  sendSms({
    body: 'Some other message message',
    recipients: ['+19999999999']
  })
]);

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.1
    9
    • latest

Version History

Package Sidebar

Install

npm i simple-sms-sender

Weekly Downloads

9

Version

0.1.1

License

MIT

Unpacked Size

11.5 kB

Total Files

12

Last publish

Collaborators

  • yorch