Confused SMS sending using aws [Updated: SMS is delivered late]

I am writing a program that sends SMS using AWS SNS service. I am new to this topic. So I tried one of the codes available on the internet.

and the code looks like this.

var AWS = require('aws-sdk');

AWS.config.region = 'your aws region';
AWS.config.update({
    accessKeyId: "your access id",
    secretAccessKey: "your secret access key",
});

var sns = new AWS.SNS();
var params = {
    Message: "your message",
    MessageStructure: 'string',
    PhoneNumber: 'phone_number_without_+',
    Subject: 'your subject'
};

sns.publish(params, function (err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else console.log(data);           // successful response
});

      

Here I filled out all the data from my console, the AWS, for example Region

, accessKey

and secretAccessKey

, up my mobile number

, Subject

and message

. after filling this in, when i try to run this i get below response.

{ ResponseMetadata: { RequestId: '30d54840-1aa8-5ad4-8de7-19cad1ed033f' },
  MessageId: '7cc1d99e-b835-5015-b84e-88147370a9fe' }

      

but there is no sms on my mobile.

I thought this service was not available in my country and then tried to send a message from the SMS console shown below. I received a text message on my mobile phone.

enter image description here

I am not using here topic

and I need to send a message individually, there is no bulk message to send.

Please give me a briefing on where I am going wrong and how I can fix it.

thank

Refresh

Thanks for the quick test balent .

This job works, the saddest part is that the message is delivered in 9 hours. I'm in India and our code starts something like this +91XXXXXXXXXX

and I did the same. But when you tried through console (SMS screenshot) the message was instant, can someone please highlight how this can be fixed. that is, sms that should be sent immediately.

+3


source to share


1 answer


Thanks for your question and updated answer to shorten India shipping time by setting the DefaultSMSType attribute to "Transactional", delivering it immediately.

sns.setSMSAttributes( { attributes : { DefaultSMSType : "Transactional" } }, function(error){ if(error){ console.log(error); } } );



Explanation: There are two types: adware, which is the default, not time-critical, and the other, transactional, time-critical used for otp. I believe there is a price difference when using either option. After reading your answer, I tried the way you did it and the sms got delayed, so I used the api given here to go to the transaction and gave instant messages.

http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html#publish-property

+2


source







All Articles