-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsms.js
31 lines (26 loc) · 875 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
29
30
31
// Import the necessary libraries and set up your Africastalking API credentials
const Africastalking = require('africastalking');
const apiKey = process.env.AT_API_KEY;
const username = 'deltabk';
// Create an instance of the Africastalking SMS service
const sms = Africastalking({
apiKey,
username,
});
// Function to send a schedule as an SMS
async function sendScheduleViaSMS(phoneNumber, schedule) {
try {
const options = {
to: [phoneNumber], // Phone number to send the SMS to
message: `Your Schedule for Today:\n${schedule}`, // Customize the SMS message
};
// Send the SMS
const response = await sms.SMS.send(options);
// Log the response
console.log('SMS sent successfully:', response);
} catch (error) {
console.error('Error sending SMS:', error);
throw error;
}
}
module.exports = { sendScheduleViaSMS };