I saw that it's now possible from the AWS website (https://aws.amazon.com/about-aws/whats-new/2020/10/amazon-sns-now-supports-selecting-the-origination-number-when-sending-sms-messages/), but couldn't find anything related to it for aws-sdk-js
Asked
Active
Viewed 2,409 times
1 Answers
7
(Acquired from the support)
===========================
exports.handler = function(event, context, callback) {
var AWS = require('aws-sdk');
// Set region
AWS.config.update({
region: 'us-east-1'
});
// Create publish parameters
var params = {
Message: 'test message’,
MessageAttributes: {
'AWS.MM.SMS.OriginationNumber': {
DataType: 'String',
StringValue: '+12345678910' // origination number should be in E.164 format
},
},
PhoneNumber: '+1xxxxxxxxxxx’ // destination number should be in E.164 format
};
// SNS service object
var sns = new AWS.SNS();
var publishText = sns.publish(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
};
============================

Scrandre
- 141
- 8
-
1thanks, but didn't work for me. – Peppershaker Jan 04 '22 at 21:12
-
2edit: this setting will only be respected if the OriginationNumber sending the SMS and the receiving number are in the same country. Canada and US all have +1 but that's not enough. – Peppershaker Jan 04 '22 at 21:22