How can i send AWS SNS HTTP dynamically to certain subscribers - amazon-web-services

I am sending many messages but the subscribers change very often (per message), how can can i choose my specific subscribers on every message? the number of possibilities is too much to create topic to each combination.

You can't. A message is delivered to all subscribers of the SNS topic.
Once you subscribe an endpoint to a topic and the subscription is
confirmed, the endpoint will receive all messages published to that
topic. Source

You can manage the endpoints yourself on the back end. You then publish to an individual endpoint. For large groups you will have to build in flood protection.

Related

Amazon SES using Message Id

Im using AWS Lambda for sending emails by Amazon SES.
Each time that the request send_email succeeds I got the message id like confirmation.
But now, I want to use somehow this messageId. For example to know if this message concretelly get delivered or bounced.
CloudWatch offers me metrics, with the number of delivered or bounced messages but I want to look throught each one.
¿Is there any statement that allows to know the state of a message by id?
Due to the asynchronous nature of SMTP and how mails are being routed, you can't have this information immediately when sending an e-mail (via SES or otherwise).
However, AWS provides a feedback system which notifies an SNS topic when a message is delivered, bounced, or a complaint was received.
While the documentation is very detailed, the general idea is that you subscribe your own lambda(s) to the configured SNS topic(s) and you can then handle these events as you see fit (i.e. persist data on DynamoDB, call your unsubscribe API and so on).

Can we save client SMS responses in AWS Pinpoint's 2-way SMS?

I know that Amazon Pinpoint enables 2-way SMS, but I was wondering whether it was possible to save the message that the client sends. I'm finding myself going down the AWS rabbit-hole a bit, but I was wondering if anyone has any recommendations as to what AWS services could hold onto response data.
Just to clarify, I understand that Pinpoint allows us to return automated messages when the client passes a keyword. I am also aware that we can create user segments to save user attributes, I am moreso inquiring whether there is a way to stream user responses (that are not keywords) to another service or topic. Thank you!
An overview of Amazon Pinpoint two-way messaging can be summarized as per the above sample architecture.
You can capture the incoming messages from your users using the SNS topic you would have created when activating Pinpoint two-way messaging i.e When your users reply to your SMS message using the long code number, Amazon Pinpoint sends a JSON payload to the Amazon SNS topic that you designated. As a developer you handle these incoming messages by adding subscriptions to this SNS topic. The supported subscriptions include SQS, Lambda, email, HTTPS endpoint or SMS.
A sample JSON payload that your SNS topic subscriptions would receive would resemble the following :
{
"originationNumber":"+27155550000",
"destinationNumber":"+2722255511111",
"messageKeyword":"START",
"messageBody":"Hello World from Amazon Pinpoint",
"inboundMessageId":"cae173d2-66b9-564c-8309-66b9",
"previousPublishedMessageId":"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
}
Hope this Helps!

Can I publish to a specific subscription in a SNS topic?

When I publish to a topic it hits ALL subscribers ALWAYS?
I have a topic with several subscriptions, sometimes I want to publish a message to just one of those subscriptions.
Is there a way to do this or do I need to create another topic and have the subscription in 2 topics? In that case I'm bugging the user (assuming this use case is to message users) twice right?
Yes -- when a message is sent to an Amazon SNS topic, all subscribers receive the message.
If you wish to contact a specific subscriber, your code will have to contact them directly (eg via email).
Amazon SNS also has the ability to send an SMS message to one or more recipients without using an SNS Topic. So, if your desired recipients are on SMS, this is a simple task.

Amazon-SNS. Limit delivery to SMS protocol while publishing

We are using Amazon SNS to sent SMS to customers through API(PHP). The topic may have email subscriptions as well as SMS subscriptions. I.e While creating a subscription,protocol may be email/sms. But we want to sent only SMS while publishing the messages. Email subscriptions should not receive any message. How to archive this?
This is not possible. All subscribers to the topic will be sent the message.
You can provide different versions of messages for different types of subscriptions (eg SMS vs email), but you cannot control which type of subscriber receives a message.
Some alternatives:
Maintain separate topics for situations where you wish to send a notification only to a subset of subscribers
Use Amazon Pinpoint to specifically target mobile users with notification campaigns

AWS SNS Mobile Push based on user notification preferences

I'm working SNS Push notifications into an app that I'm building, and I'm wondering how to handle user notification settings? What I don't understand is if SNS provides a way to manage a user who wants to receive notification type "A", but not type "B". A more real-world correlation is managing a Facebook user who wants notifications for comments, but not likes. Does SNS provide an easy way to manage this?
I can manage it myself through my own servers/databases, but this seems like something that SNS should be able to do.
I would suggest each notification type is a different SNS topic. That way the user can control each topic he is subscribed too. That puts more work for you in your app but this way you get to your designed goal of allowing each user to subscribe to each a different type of notification.
Topics are free but SNS messages sent are charged.
FREE TIER: Each month, Amazon SNS customers receive 1,000,000 Amazon SNS Requests, 100,000 HTTP notifications, 1,000 email notifications and 100 SMS notifications for free.
Cost calculator: http://calculator.s3.amazonaws.com/index.html
SNS Pricing Details: https://aws.amazon.com/sns/pricing/
No. SNS does not provide a way to manage users to subscribe based on notification types
In fact there is no implicit notification type definitions. Although you can have that as part of your payload.
So you can either
Have different topics for different notification types and then attach subscribers based on which type of messages they are interested in
Have a type definition defined within the payload and then let the filtering happen at the subscribers. But keep in mind that this will be costly affair because all subscribers receive all notifications and you can soon exhaust your free limit. Also the subscribers will receive unnecessary load