Library to send SMS messages to multiple recipients using Twilio API.
yarn add simple-sms-sender
or
npm install --save simple-sms-sender
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
});
sender.sendMultipleSms([
{ body: '', recipients: [] },
{ body: '', recipients: [] }
]);
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,
secret,
sid
});
};
const smsSender = createSender();
smsSender.sendMultipleSms([
{
body: 'Some message',
recipients: ['+19999999999', '+18888888888']
},
{
body: 'Some other message message',
recipients: ['+19999999999']
}
]);