-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendSms.js
More file actions
21 lines (17 loc) · 711 Bytes
/
sendSms.js
File metadata and controls
21 lines (17 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require('dotenv').config();
const twilio = require('twilio');
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const fromNumber = process.env.TWILIO_SENDER_PHONE_NUMBER;
const toNumber = process.env.TWILIO_RECEIVER_PHONE_NUMBER;
const messageBody = process.env.TWILIO_MESSAGE_TO_BE_RECEIVED;
const client = new twilio(accountSid, authToken);
const sendAnonymousSms = (to, from, body) => {
client.messages.create({
body: body,
from: from,
to: to
}).then(message => console.log(`Message sent with SID: ${message.sid}`))
.catch(error => console.error('Error sending message:', error));
};
sendAnonymousSms(toNumber, fromNumber, messageBody);