-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
55 lines (44 loc) · 1.43 KB
/
server.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//requirements
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const bandwidth = require("node-bandwidth");
//initialize app
const app = express();
const port = process.env.PORT || 3000;
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, "/public")));
require("./routes/routes.js")(app);
//initialize Bandiwdth client
const client = new bandwidth({
userId : "{{USER_ID}}",
apiToken : "{{TOKEN}}",
apiSecret : "{{SECRET}}"
});
//SMS reminder function
function sendReminderSMS(){
//first, pull info about the client
//(their phone number and the date and time of their appointment)
//from whatever database you are using
//and set variables
let apptDate = "{{DATE}}";
let apptTime = "{{TIME}}";
let clientNum = "{{CLIENT_NUMBER}}";
let BWNum = "{{YOUR_BANDWIDTH_NUM}}";
//create outgoing SMS
client.Message.send({
from: BWNum,
to: clientNum,
text: "This is a reminder that you have an appointment at {{OFFICE NAME}} on " + apptDate + " at " + apptTime + ". Text YES to confirm your appointment."
}).then(message => {
console.log(message);
});
}
//set SMS reminder function
//to run once a day
setInterval(sendReminderSMS, 86400000);
//listen
app.listen(port, function() {
console.log("App listening on PORT " + port);
});