Passing custom senderID and templateID for AWS SNS in India using NodeJS

0

So, I am trying to figure out the NodeJS Code for sending SMS to Indian mobile numbers using AWS SNS. I have gotten the code down to sending the SMS but I am not able to map the senderID or the templateID which I have gotten registered. The DLT Template ID has been registered with Airtel DLT Connect and even the entityID has been registered there. I am getting the SMS but with a random senderID, not the one I am assigning. The code snippet is below:

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

var config = {
    AWS: {
        accessKeyId: "",
        secretAccessKey: "",
        region: "ap-south-1"
    }
}

AWS.config.update({
    accessKeyId: config.AWS.accessKeyId,
    secretAccessKey: config.AWS.secretAccessKey,
    region: config.AWS.region
});

var params = {
    Message: "Your verification code is 123345. This code is valid for 24 hours.",
    MessageStructure: 'string',
    PhoneNumber: '+91XXXXXXXXXX',
    MessageAttributes: {
        "AWS.SNS.SMS.SenderID": {
            DataType: 'String', StringValue: 'CustomSenderID'
        },
        "AWS.SNS.SMS.SMSType": {
            DataType: 'String', StringValue: 'Transactional'
        },
        "AWS.MM.SMS.EntityID": {
            DataType: 'String', StringValue: 'EntityID'
        },
        "AWS.MM.SMS.TemplateId": {
            DataType: 'String', StringValue: 'TemplateID'
        }
    }
};

var sns = new AWS.SNS();

sns.publish(params, function (err, data) {
    if (err) {
        console.log(err);
    } else {
        console.log(data);
    }
});

So, if I don't pass the EntityID and the templateID, I get the SMS but with a random numeric senderID. When I try to pass it in the example shown above, I get the below error:

ParameterValueInvalid: Message attribute names starting with 'AWS.' or 'Amazon.' are reserved for use by Amazon.
    at Request.extractError (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\protocol\query.js:50:29)
    at Request.callListeners (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\request.js:686:14)
    at Request.transition (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\request.js:688:12)
    at Request.callListeners (D:\WORK\Agri10x\Development\Projects\dataserver\node_modules\aws-sdk\lib\sequential_executor.js:116:18) {
  code: 'ParameterValueInvalid',
  time: 2022-01-06T09:33:30.590Z,
  requestId: 'dc92b0a1-e561-5ae4-a32d-eaf15ccb3fea',
  statusCode: 400,
  retryable: false,
  retryDelay: 57.53422286102854
}

Any help would be appreciated! Thanks in advance!

gefragt vor 2 Jahren767 Aufrufe
3 Antworten
1

Use 'AWS.MM.SMS.EntityId' in your code and it should work. Secondly, you need to request the SenderID using https://docs.aws.amazon.com/sns/latest/dg/sns-india-request-sender-id.html

HTH

Aarcaa
beantwortet vor einem Jahr
0

Hi, Were you able to figure out the issue?

beantwortet vor 2 Jahren
0

Hi Team, No not yet unfortunately. Just stuck at the same place

beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen