AWS - SNS (India Text Message) Not sending via Local Routes - amazon-web-services

Am Using the Java API to try to send SMS to India Numbers.
I have a valid Entity ID and Template ID registered using JIO DLT (https://trueconnect.jio.com/#/)
I am setting Messaage Attributes as following
AWS.SNS.SMS.SMSType - Transactional
AWS.SNS.SMS.SenderID - <My Registered Sender ID>
AWS.MM.SMS.EntityId - <DLT provided Entity ID>
AWS.MM.SMS.TemplateId - <Template ID of the message i want to send>
Am using software.amazon.awssdk.services.sns.SnsClient to send the Request as below...
PublishRequest pb = PublishRequest.builder()
.message(message)
.phoneNumber(snsDefaultCountryCode+to)
.messageAttributes(smsAttributes).build();
PublishResponse result = snsClient.publish(pb);
I do receive the SMS, but via ILDO with international charges. I was expecting the message to go via local routes or at least a response with error 'Entity ID is invalid' or 'Template ID is invalid' etc.
Are there any other steps to do before sending SMS to india using the AWS services?

I believe you need to register the DLT sender id with AWS using a service limit support request on Pinpoint SMS Service.
After AWS support team approves your request, which may take upto 24 hours your SMS will get routed via India with sender id
Please find the reference link for the same here

Related

Get success status AWS SES

Prerequisites
I use AWS SES to send an email with event publishing to track the delivery status.
Problem
I'm looking for an event to make sure that an email is successfully sent to the end-user.
Description
Following AWS documentation, this type is suitable:
Deliveries – Amazon SES successfully delivered the email to the
recipient's mail server.
However, this event I get also in case Hard bounces.
For example, email status flow is:
Sends -> Deliveries - in case of successfull delivery
Sends -> Deliveries -> Hard bounces - in case I provide invalid recipient name, e.g. invalid#domain.com or 1234567890#domain.com
I don't expect Hard bounces after Deliveries.
If this behavior is correct then I need some additional event for sure success.
Something like this is expected in case of successfull delivery:
Sends -> Deliveries -> Success
I know that there are other "success" events like Opens, Clicks, Subscriptions, but they require additional action from the end-user.
Implementation details
I use Verified identity as an email sender.
A configuration set is used to redirect status events to SNS.
Finally, SQS is subscribed to this SNS to have all events in one place.
I tried several ways to send an email:
Java code using AWS SES SDK
Sending simulator with predefined and custom recipient's
The result is the same (as described above)
I think it is impossible to have a Success status because AWS cannot guarantee when the recipient mail server will reply with a Hard Bounce. You yourself have to define how long to you want to wait until you consider a delivery as successful. For example, if no hard bounce after 5 minutes, then it is a success.
If your use case is for analytics, I will simply capture more event types (for example log both Deliveries and Hard Bounces), and then count my success as Count of Deliveries - Count of Hard Bounces.
If your use case is for event-driven workloads, we need to define first what is considered a Success. For example, if we define Success as no Hard Bounce after 5 minutes, we can configure a Lambda function to trigger 5 minutes after a Delivery event. In the function, check if a subsequent Bounce event occurred. If not, the delivery is considered successful and then you can proceed to do what you want to do.
This is what I got from aws support about delivery status of an email.
Amazon SES will continue making several delivery attempts until
receiving a successful response from the recipient mail server, or
until 840 minutes elapse. If Amazon SES is still unable to deliver
the email/message during this period, it stops sending the email and
will then return a bounce message/notification.
According to this you can't be sure about the bounce or any other status within 5 minutes.
AWS does not have visibility to confirm if the Recipient Mail Server was able to deliver the message to the recipient email address when you get a 250 OK(it's confirmation that aws has delivered the message to recipient's mail server).
So there is no way you can be sure.

Do I have to change to AWS Pinpoint to use 10DLC for sending SMS messages or can I still use AWS SNS

Brief Description:
What is an unregistered long code when it comes to an application sending SMS messages?
Plus, I'm using AWS SNS to send text messages through a node js application. Do I have to switch to Amazon Pinpoint to send to SMS messages?
Detailed:
I got an email from AWS saying that the US telecom carriers would no longer support sending Application-To-Person (A2P) SMS messages over unregistered long codes
It then says If you are using long codes, Amazon strongly recommends that you complete the transition to toll free numbers, 10DLC, or short codes.
In addition to that it appears that AWS wants me to use Amazon Pinpoint to send sms messages and email. And the deadline to make the change is on June 1, 2021.
First off, whats an unregistered long code? I imagine those are the long international phone #'s you'd see for someone in Europe or Latin America. But to be sure I looked at AWS's docs and don't really see an example of one.
I have a node app running on an EC2 instance that uses AWS SNS to send messages to US text messages based off certain business logic. The phone numbers in the config files have the following format: US Country Code - 10 Digit phone Number so an example is +13215441222 which is a 10DLC plus the us country code.
In other words, my app is already sending text messages using 10DLC but its doing so using AWS SNS. So do I even have to do anything that the AWS email recommends?
I don't have aws support to ask them this question so I'm asking it here.
In addition to that it appears that AWS wants me to use Amazon Pinpoint to send sms messages and email.
You can still use SNS to send SMS messages, either using 10DLC, short codes or toll-free.
First off, whats an unregistered long code?
It is any number used in application-to-person (A2P) SMS messaging not registered with The Campaign Registry (TCR)
Let me quote documentation:
In order to use a 10DLC number, first register your company and create a 10DLC campaign using the Amazon Pinpoint (not Amazon SNS) console. AWS shares this information with The Campaign Registry, a third party that approves or rejects your registration based on the information. In some cases, registration occurs immediately. For example, if you've previously registered with The Campaign Registry, they might already have your information. However, some campaigns might take one week or longer for approval. After your company and 10DLC campaign are approved, you can purchase a 10DLC number and associate it with your campaign. Requesting a 10DLC might also take up to a week for approval. Although you can associate multiple 10DLCs with a single campaign, you can't use the same 10DLC across multiple campaigns. For each campaign you create, you need to have a unique 10DLC.
Reference: https://docs.aws.amazon.com/sns/latest/dg/channels-sms-originating-identities-10dlc.html
So do I even have to do anything that the AWS email recommends?
Yes, you need to switch to 10DLC, toll-free or short codes.
Short codes reference: https://docs.aws.amazon.com/sns/latest/dg/channels-sms-originating-identities-short-codes.html
Blog post about 10DLC: https://aws.amazon.com/blogs/compute/provisioning-and-using-10dlc-origination-numbers-with-amazon-sns/

Has anyone built an integration with any SMS Receivers?

I want to be able to send a text message to some number and then (upon receiving the text) basically just send a post request off to a different service after receiving the text. Does anyone know of a service I could use to set this up? Would like for it to be as fast as possible
Here's a summary of the steps to setup a sample app:
Navigate to Amazon SNS Service → Topics
Enter Name and create a new Topic
For the newly created topic, create a subscription where the Protocol is AWS Lambda (see image1 below)
Navigate to Amazon Pinpoint Service, create new Pinpoint application
Enable SMS & voice feature for this Pinpoint application
Get a new Long Code (long code price is $1/month)
For the long code, Enable two-way SMS, select the Choose an existing SNS topic option and select the SNS topic created in Step 2 above (see image2 below)
Finally, now you can send a message to that phone number from your phone and it will trigger your lambda function. In your lambda function, you can send a POST request to a different service or do whatever else. You can also respond back to the user's message - see example below.
Here's an example of how to send a message using Amazon Pinpoint in Java:
public void sendSMS(String pinpointPhoneNumber, String userPhoneNumber, String messageContent) {
// define who the message is going to and via what platform
Map<String, AddressConfiguration> addressMap = new HashMap<>();
addressMap.put(userPhoneNumber, new AddressConfiguration().withChannelType(ChannelType.SMS));
SMSMessage smsMessage = new SMSMessage();
smsMessage.setOriginationNumber(pinpointPhoneNumber);
smsMessage.setMessageType(MessageType.TRANSACTIONAL);
smsMessage.setBody(messageContent);
// add sms message to the direct message config
// this can have many other types of messages
DirectMessageConfiguration directMessageConfiguration = new DirectMessageConfiguration()
.withSMSMessage(smsMessage);
// put the phone numbers and all messages in here
MessageRequest messageRequest = new MessageRequest()
.withAddresses(addressMap)
.withMessageConfiguration(directMessageConfiguration);
// create send request
SendMessagesRequest sendMessagesRequest = new SendMessagesRequest()
.withApplicationId("put-pinpoint-app-id-here")
.withMessageRequest(messageRequest);
// send the message
AmazonPinpoint pinpointClient = AmazonPinpointClientBuilder.standard().build();
SendMessagesResult sendMessagesResult = pinpointClient.sendMessages(sendMessagesRequest);
MessageResponse messageResponse = sendMessagesResult.getMessageResponse();
}

How can I get certificate_id and client_id in AWS IoT Lambda?

I am using AWS IoT Core. I've created client side certificate for the device following https://aws.amazon.com/blogs/iot/just-in-time-registration-of-device-certificates-on-aws-iot/. Everything went fine. Problem is that now I want to save client certificate_id and client_id in same table to make a relation between them, but I could not get certificate_id and client_id in one lambda invokation.
for example:
when device make first time conection with its client certificate to IoT server, lambda gets certificate_id but does not get client_id
{
"client_id":"N/A",
"certificateId":"",
"caCertificateId":"",
"timestamp":"",
"certificateStatus":"PENDING_ACTIVATION",
"awsAccountId":"",
"certificateRegistrationTimestamp":""
}
afterwards on publishing any topic I can get client_id but does not get certificate_id
I've tried to get client_id by this rule when first time client make connection to IoT.
SELECT clientId() as client_id , * FROM '$aws/events/certificates/registered/111111111111111'
On Lambda I print event:
{
client_id: 'N/A',
certificateId: '222222',
caCertificateId: '111111111111111',
timestamp: 3333,
certificateStatus: 'PENDING_ACTIVATION',
awsAccountId: '44444',
certificateRegistrationTimestamp: '55555'
}
here "1111.." is my CA certificate.
I want to get certificate_id so that I can active or deactive device using boto3 iot function
response = client.update_certificate(
certificateId='string',
newStatus='ACTIVE'|'INACTIVE'
)
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iot.html#IoT.Client.update_certificate
You can subscribe to connect events on the topic
$aws/events/presence/connected/+
This will allow you to correlate client Id to principal id (certificate).
See https://docs.aws.amazon.com/iot/latest/developerguide/life-cycle-events.html

Send SMS with custom sender id using amazon notification service

Iam using amazon notification service for sending SMS. i successfully got the message to my number. i have updated the sender id using aws console like this.
But i got SMS like this
from : VK-NOTICE
Body : test message
from id is diifrent. why? is it possible to change sender id ?
According to TRAI length of sender id in transactional sms should be 6 in India and yours is 5 (MANAF) that's why it is changing it to default. To use your sender id in transactional sms use id with character length of 6. Ex(AbdulM)
Note: It only works with transactional Sms.
AWS Docs have the answer here:
For Default sender ID, type a custom ID that contains up to 11 alphanumeric characters, including at least one letter and no spaces.
The sender ID is displayed as the message sender on the receiving
device. For example, you can use your business brand to make the
message source easier to recognize.
Support for sender IDs varies by country. For example, messages
delivered to U.S. phone numbers will not display the sender ID. For
the countries that support sender IDs, see Supported Regions and
Countries.
If you do not specify a sender ID, the message will display a long
code as the sender ID in supported countries. For countries that
require an alphabetic sender ID, the message displays NOTICE as the
sender ID.
You can override the this setting when you send a message.
You should try https://www.twilio.com/
As on 2 Nov 2018, Custom sender ID is not supported for India. See below link for current supported countries.
AWS SNS Supported Countries