5

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

Scrandre
  • 141
  • 8

1 Answers1

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