generated from lighthouse-labs/node-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsend-message.js
38 lines (28 loc) · 1 KB
/
send-message.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
//to load .env content
require('dotenv').config();
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
function sendOrderConfirmation() {
client.messages
.create({
body: 'Your order has been received. You will receive a text-message when your order is ready for pick-up',
from: process.env.TWILIO_FROM_NUMBER,
to: process.env.TO_NUMBER
})
.then(message => {
console.log(message.sid);
//After 10 sec, send an order pickup message
setTimeout(() => {
client.messages
.create({
body: "Your order is ready for a pick-up. Thank you for choosing Calcifer's Hearth!",
from: process.env.TWILIO_FROM_NUMBER,
to: process.env.TO_NUMBER
})
.then(pickupMessage => console.log(pickupMessage.sid));
}, 10000);
});
};
// sendOrderConfirmation();
module.exports = {sendOrderConfirmation}