JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 41
  • Score
    100M100P100Q95458F
  • License MIT

Simple SMS sender to multiple recipients using Twilio

Package Exports

  • simple-sms-sender
  • simple-sms-sender/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (simple-sms-sender) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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({
  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']
  })
]);