generated from lighthouse-labs/node-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtwilio.js
32 lines (29 loc) · 1013 Bytes
/
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
28
29
30
31
32
const twilio = require('./lib/twilio_config');
const client = require("twilio")(twilio.accountSid, twilio.authToken);
const sendRestaurantMessage = function() {
console.log("sending message...");
client.messages
.create({
body: "Hi there, a customer has placed an order. Please head over to Restaurant Portal to accept and provide estimated wait time",
from: twilio.phoneNumber,
to: "+17786809238"
})
.then(message => console.log("message id: " + message.sid))
.catch(err => {
console.log(err);
});
};
const sendCustomerMessage = function(name, phone, waitTime) {
console.log("sending message...");
client.messages
.create({
body: `Hi ${name}, your order has been accepted! Estimated wait time: ${waitTime}`,
from: twilio.phoneNumber,
to: phone
})
.then(message => console.log("message id: " + message.sid))
.catch(err => {
console.log(err);
});
};
module.exports = { sendRestaurantMessage, sendCustomerMessage };