-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendMessage.js
More file actions
32 lines (26 loc) · 942 Bytes
/
sendMessage.js
File metadata and controls
32 lines (26 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require("dotenv").config();
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require("twilio")(accountSid, authToken);
function sendMessage(message, outgoingPhoneNumber) {
client.messages
.create({
body: message,
from: "+18443871906",
to: outgoingPhoneNumber,
})
.then((message) => console.log(message.sid));
}
function messageAllEmployees() {
const employees = [
{ name: "Tim", phoneNumber: "+14696056677" },
{ name: "Amrit", phoneNumber: "+18178881378" },
{ name: "Abdullah", phoneNumber: "+15106760469" },
{ name: "Farhan", phoneNumber: "+13462199977" },
];
employees.forEach((employee) => {
const message = `Hey ${employee.name}, have you spoken to Tim lately? We were wondering how he's doing.`;
sendMessage(message, employee.phoneNumber);
});
}
module.exports = { sendMessage, messageAllEmployees };