twilio-sms

1.0.2 • Public • Published

TWILIO_SID= TWILIO_TOKEN= TWILIO_MSID=

const acc_sid = process.env.TWILIO_SID;
const auth_token = process.env.TWILIO_TOKEN;
const client = require("twilio")(acc_sid, auth_token);

// Default sid in ENV
const send_sms = async ({ to, sid = process.env.TWILIO_MSID, message }) => {
  try {
    const res = await client.messages.create({
      body: message,
      messagingServiceSid: sid,
      to: to,
    });

    return res._id;
  } catch (error) {
    console.log(error);
    return false;
  }
};

// Dont have to add + to filed "to", add phone directly
send_sms({to:"xxxxxxxxxxx",message:"Your message here"})

Readme

Keywords

none

Package Sidebar

Install

npm i twilio-sms

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

1.43 kB

Total Files

3

Last publish

Collaborators

  • bankonly