1.0.2 • Published 2 years ago
twilio-sms v1.0.2
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"})