Skip to content

Instantly share code, notes, and snippets.

@avtaniket
Created January 4, 2017 12:13
Show Gist options
  • Select an option

  • Save avtaniket/9dcc1fe6c3ce24f2ca34c324dab505e6 to your computer and use it in GitHub Desktop.

Select an option

Save avtaniket/9dcc1fe6c3ce24f2ca34c324dab505e6 to your computer and use it in GitHub Desktop.
AWS SNS send SMS to mobile number
var awsSdk = require('aws-sdk');
awsSdk.config.update({
accessKeyId: 'ACCESS_KEY_ID',
secretAccessKey: 'SECRET_ACCESS_KEY'
});
/**
* [sendSMS - Send SMS to given number]
* @param {object} params {message : string, number : number}
* @param {Function} callback
*/
function sendSMS(params, callback) {
var sns = new awsSdk.SNS({
region: 'us-east-1'
});
var smsParams = {
Message: params.message,
MessageStructure: 'string',
PhoneNumber: params.number
};
sns.publish(smsParams, function(err, data) {
if (err) {
console.log(err);
logger.error('sns sms', err);
callback('Unable to send sms');
} else {
callback();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment