-
-
Save luisloaiza/a01e96606ab0b68a9a61538c280b003e to your computer and use it in GitHub Desktop.
Send SMS Amazon SNS Nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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
Thanks for the above information.
In the recent version, subject not working as expected.
Just to mentioned here about update of publish request payload.