Skip to content

Instantly share code, notes, and snippets.

@hiukky
Forked from luisloaiza/send_sms.js
Created September 23, 2019 19:12
Show Gist options
  • Save hiukky/7d6b8eebcf4c8e27da33ae58d45cd4a0 to your computer and use it in GitHub Desktop.
Save hiukky/7d6b8eebcf4c8e27da33ae58d45cd4a0 to your computer and use it in GitHub Desktop.
Send SMS Amazon SNS Nodejs
/*
AWS implementation of SMS messaging
A simple sample that can become a lib.
*/
// npm install aws-sdk -g
const AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: process.env.AMAZON_ACCESS_KEY_ID,
secretAccessKey: process.env.AMAZON_SECRET_ACCESS_KEY,
region: 'us-west-2'
});
const sns = new AWS.SNS();
//exports.sendSMS =
function sendSMS(to_number, message, cb) {
sns.publish({
Message: message,
Subject: 'Admin',
PhoneNumber:to_number
}, cb);
}
// Example
sendSMS("+525....", "Sms text message", (err, result)=>{
console.log("RESULTS: ",err,result)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment