Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change SMS type with AWS.SNS.publish

I am using AWS-SDK for Node.js and I would like to change the SMS type when using the SNS publish method, i.e. from Promotional to Transactional. I know I have to use the MessageAttributes property but the documentation is not quite clear how I should do this.

What parameter or property should I add to MessageAttributes object/map?

like image 561
Jonas Tomanga Avatar asked Oct 06 '18 22:10

Jonas Tomanga


People also ask

What is the format of structured notification messages sent by Amazon SNS?

The notification message sent by Amazon SNS for deliveries over HTTP, HTTPS, Email-JSON and SQS transport protocols will consist of a simple JSON object, which will include the following information: MessageId: A Universally Unique Identifier, unique for each notification published.

How do I publish a message on SNS?

Sign in to the Amazon SNS console . In the left navigation pane, choose Topics. On the Topics page, select a topic, and then choose Publish message. The console opens the Publish message to topic page.

Can SNS send texts?

You can use Amazon SNS to send text messages, or SMS messages, to SMS-enabled devices. You can send a message directly to a phone number, or you can send a message to multiple phone numbers at once by subscribing those phone numbers to a topic and sending your message to the topic.


1 Answers

After a long search this is what worked for me:

AWS = require('aws-sdk')

(new AWS.SNS()).publish({
   Message: 'Message',
   PhoneNumber: '+XXX',
   MessageAttributes: {
    'AWS.SNS.SMS.SMSType': {
       DataType: 'String',
       StringValue: 'Transactional'
    }
 });

The attribute you must add is 'AWS.SNS.SMS.SMSType'

like image 174
Jonas Tomanga Avatar answered Oct 12 '22 01:10

Jonas Tomanga