-
-
Save hiukky/7d6b8eebcf4c8e27da33ae58d45cd4a0 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