I am using AWS Lambda in with node.js code to send SMS onto the device. It works plenty of times but sometimes even after the Sucess response message the SMS is not received by device. Below is the code I used:
'use strict';
console.log('Loading function');
var AWS = require("aws-sdk");
var sns = new AWS.SNS();
let doc = require('dynamodb-doc');
var util = require('util');
exports.handler = (event, context, callback) => {
sendSMS(context);
};
function sendSMS(context) {
var phone = '+91xxxxxxxxxx';
var message = "Hi! Just one more way to test the functionality";
var params = {
'PhoneNumber': phone,
'Message': message
};
sns.publish(params, function(err, data) {
if (err) {
context.fail(err);
} else {
console.log(util.inspect(data));
console.log('Message Sent successfully')
}
});
}
Please help me here to find the exact reason for the same and suggest the solution.