-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsms.js
28 lines (24 loc) · 827 Bytes
/
sms.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
// Download the helper library from https://www.twilio.com/docs/node/install
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const twilioNumber = process.env.TWILIO_FROM_NUMBER
const client = require('twilio')(accountSid, authToken);
module.exports = {
sendMessage: async function(sendMsg, toNumber)
{
if(!toNumber)
{
return 'no_number'
}
let status = await client.messages
.create({
body: sendMsg,
from: twilioNumber,
to: toNumber
})
.then(message => { return message.status });
return status
}
}