-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwilio.js
27 lines (24 loc) · 1.05 KB
/
twilio.js
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
/* global process, require */
(function () {
var moment = require("moment");
var repo = require("./repository");
// Your accountSid and authToken from twilio.com/user/account
// Need to be added to twilio-config.json with accountSid and authToken properties defined
var config = require("./twilio-config.json");
var client = require("twilio")(config.accountSid, config.authToken);
var tomorrow = moment().add(1, "day"),
query = { day: tomorrow.get("weekday") };
repo.get("Notification", query).then(function (notifications) {
console.info(notifications.length, "notifications to send");
notifications.forEach(function (notification) {
console.info("Sending SMS message", notification.number);
client.messages.create({
body: "Tomorrow is pick-up day!",
to: notification.number,
from: "+17047692783"
}, function(err, message) {
process.stdout.write(message.sid);
});
});
});
})();