0

Hey everyone so I am trying to send an SMS message via amazon pinpoint using a toll-free number via nodejs. Note the numbers in this code have been changed for security. Heres my code:

router.get("/send-text", async (req, res, next) => {
  try {
    const sender = "+18446850251";
    const destinationNumber = "+14325948991";
    const message = "HELLO from AWS";
    const applicationId = "myApplicationId";
    const messageType = "TRANSACTIONAL";
    AWS.config.update({ region: "us-east-1" });
    const pinpoint = new AWS.Pinpoint();
    const params = {
      ApplicationId: applicationId,
      MessageRequest: {
        Addresses: {
          [destinationNumber]: {
            BodyOverride: message,
            ChannelType: "SMS"
          }
        },
        MessageConfiguration: {
          SMSMessage: {
            Body: message,
            MessageType: messageType,
            OriginationNumber: sender
          }
        }
      }
    };
    const result = await pinpoint.sendMessages(params).promise();
    res.send(result);
  } catch (error) {
    console.log(error);
    next(error);
  }
});

Upon running this code I get the following response:

{
MessageResponse: {
ApplicationId: "myApplicationId",
RequestId: "8beaebf0-f33a-42d3-bb88-1f3efcf493eb",
Result: {
+14325948991: {
DeliveryStatus: "PERMANENT_FAILURE",
StatusCode: 404,
StatusMessage: "Resource not found"
}
}
}
}

Side note: the reason I am doing this is that I received an email from AWS and my understanding is that I can no longer send text messages via the application to a person (a 10 digit long code) via SNS topics and must send them via pinpoint using a 10DLC long code or toll-free number starting June 1st is that correct?

image of settings

2 Answers2

0

Your assumption is correct as stated in this AWS document: https://docs.aws.amazon.com/sns/latest/dg/channels-sms-awssupport-long-code.html

I just tested this using these values:

    String message = "This is a Pinpoint test"; 
    String appId = "2fdc4442c6a2483f85eaf7a9430xxxxx";
    String originationNumber = "+14387956xxx" ;
    String destinationNumber = "+18195765xxx" ; 
    System.out.println("Sending a message" );

Response was:

+18195765xxx:MessageResult(DeliveryStatus=SUCCESSFUL, MessageId=4eniddp3gqrsarku8q2i2vnqqo0v8eov0t1dhs80, StatusCode=200, StatusMessage=MessageId:

The app id can be obtained from the AWS Management Console:

enter image description here

To get the origination number - you request a code in the AWS Console and use that in your app logic:

enter image description here

smac2020
  • 9,637
  • 4
  • 24
  • 38
0

SNS messaging was not explicitly enabled. Make sure you double-check this setting