AWS SNS SMS log status SUCCCESS but not delivered to end user - amazon-web-services

I am sending SMS to Indian mobile numbers using SNS production account(not configured SenderId) in ap-south-1 region with boto3 api using below code
sns = boto3.client('sns',region_name='us-east-1')
number = "+91"+user_mobile_number
content = sns.publish(PhoneNumber=number, Message="Dear Customer, Use this to verify your mobile:"+verification_code+"")
SMS logs shows success status for all but only first SMS is delivered correctly and all other SMS are not delivered.
SMS delivered correctly at random times.
As per aws documentation, to send SMS to India using AWS SNS suggests to register with TRAI,
Trying to debug but cannot find why the SMS are not delivered, is there any restrictions in sending SMS to indian numbers ?
Is it mandatory to register TRAI to send SMS to Indian number?

Related

how to add phone number in aws using python

import boto3
# Create an SNS client
client = boto3.client(
"sns",
aws_access_key_id="YOUR ACCES KEY",
aws_secret_access_key="YOUR SECRET KEY",
region_name="us-east-1"
)
# Send your sms message.
client.publish(
PhoneNumber ="+12223334444",
Message="Hello World!"
)
i have already added my number in aws SNS console ,and only to that number i can send message
if i want to send message to any other number, how can i send the messages to other phone numbers using pyhton and how can i add phone number in aws console using python
There are two ways to send messages in Amazon SNS:
Send directly to a phone number by using client.publish(PhoneNumber="..."), or
Send a message to an Amazon SNS Topic, and the message will be sent to all Subscribers of that topic
Subscriptions can be via email, SMS, HTTP Endpoint, etc.
Your code is using the first method, so it is sending the message to a specific phone number. If you actually want to send the message to multiple recipients, then create an SNS Topic, subscribe the recipients and then send the message to the SNS Topic using: client.publish(TopicArn="...")

How do i send the SMS message using Amazon SNS

I can't able to send the Text messages using Amazon Simple Notification Services(SNS). I have tried with API and Amazon Console. Both are not working. Please help me to solve the issues.
I am using Amazon Free plan account.
Amazon Sns support two diffrent type of messages
Promotions message
Transaction message
If your mobile register do not disturb or many service provider not allowed promotions messages like Verizon
Map<String, MessageAttributeValue> smsAttributes =
new HashMap<String,MessageAttributeValue>();
smsAttributes.put("AWS.SNS.SMS.SMSType",new
MessageAttributeValue().withStringValue("Transactional").withDataType("String"))
To discover why an SMS message was not sent, you can enable logging in CloudWatch Logs.
From Viewing Amazon CloudWatch metrics and logs for SMS deliveries - Amazon Simple Notification Service:
You can collect information about successful and unsuccessful SMS message deliveries by enabling Amazon SNS to write to Amazon CloudWatch Logs. For each SMS message that you send, Amazon SNS will write a log that includes the message price, the success or failure status, the reason for failure (if the message failed), the message dwell time, and other information.
I did this recently to discover why my SMS was not successful. The message said that my carrier refused the message. I discovered that this was because I was using a Custom Sender ID. Once I removed that setting, I could successfully send SMS messages.

Can I use a phone number instead of a Sender ID when sending SMS with Amazon SNS?

I am integrating AWS SNS into a project which sends transactional sms messages on a daily basis. Currently I have it working with SenderID in Germany and Sweden but I noticed that when I send to a US number it shows a phone number. This is expected according to the AWS documentation:
Support for sender IDs varies by country and/or region. For example, messages delivered to U.S. phone numbers will not display the sender ID.
This is not a problem. However, it would be easier if I could configure my SMS messages to always show a phone number and not a Sender ID as the sender.
Is it possible to configure AWS SNS to send SMS messages with a phone number as a sender instead of the Sender ID for all countries?
Currently (i.e as of 06th April 2020) Amazon Simple Notification Service (SNS) doesn't support using phone number commonly known as Long Code in place of Sender ID.
I would like to refer you to another AWS service called Amazon Pinpoint which I know supports the use Long Code.

How to respond to SMS from AWS SNS

When I receive an SMS from a friend's mobile phone, I can respond to it (as you would expect). When I receive an SMS from my application, via AWS SNS, I can not respond. Why is that? And can I configure a response phone number?
There is no in-bound SMS capability with Amazon Simple Notification Service. It is only for outbound messaging.
However, Amazon Pinpoint can respond to SMS messages, typically as part of a marketing campaign.
See: Amazon Pinpoint Launches Two-Way Text Messaging | AWS News Blog

SMS from amazon service to user's mobile number

Can we send a SMS to a mobile number through amazon service? I need to send a plain message and not notifications.
No.
Amazon Simple Notification Service (SNS) can't send SMS messages to recipients who have not opted-in to receive topic notifications.
The SMS capability in SNS is limited to users who respond affirmatively to the initial message requesting that they confirm their subscription to a topic -- for notifications.