DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Leverage AWS Textract Service for Intelligent Invoice Processing in Account Payables Testing
  • How To Set up a Push Notification Service in 30 Minutes or Less
  • A Beginner’s Guide To Building Microservices With AWS Lambda
  • Microservices With Apache Camel and Quarkus (Part 4)

Trending

  • Beyond Linguistics: Real-Time Domain Event Mapping with WebSocket and Spring Boot
  • Grafana Loki Fundamentals and Architecture
  • My LLM Journey as a Software Engineer Exploring a New Domain
  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 2
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Enhance Your Communication Strategy: Deliver Multimedia Messages With AWS Pinpoint

Enhance Your Communication Strategy: Deliver Multimedia Messages With AWS Pinpoint

Incorporate AWS Pinpoint in communication microservice to send multimedia messages with attachments like images and PDFs.

By 
Amol Gote user avatar
Amol Gote
DZone Core CORE ·
Aug. 14, 24 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
7.3K Views

Join the DZone community and get the full member experience.

Join For Free

In today's digital world, email is the go-to channel for effective communication, with attachments containing flyers, images, PDF documents, etc. However, there could be business requirements for building a service for sending an SMS with an attachment as an MMS (Multimedia Messaging Service). This article delves into how to send multiple media messages (MMS), their limitations, and implementation details using the AWS Pinpoint cloud service.  

Setting Up AWS Pinpoint Service

Setting Up Phone Pool

In the AWS console, we navigate to AWS End User Messaging and set up the Phone pool. The phone pool comprises the phone numbers from which we will send the message; these are the numbers from which the end user will receive the MMS message.  

AWS End User Messaging

Figure 1: AWS End User Messaging

Phone Pool

Figure 2: Phone Pool

We can add the origination numbers once the phone pool has been created. The originating numbers are 10DLC (10-digit long code). A2P (application-to-person) 10DLC is a method businesses use to send direct text messages to customers. It is the new US-wide system and standard for companies to communicate with customers via SMS or MMS messages. 

Configure Configuration Set for Pinpoint MMS Messages

After creating the phone pool, we create the configuration set required to send the Pinpoint message. 

Configuration Set

Figure 3: Configuration Set

Configuration sets help us log our messaging events, and we can configure where to publish events by adding event destinations. In our case, we configure the destination as CloudWatch and add all MMS events.

Configuration Set Event destinations

Figure 4: Configuration Set Event destinations

Now that all the prerequisites for sending MMS messages are complete let's move on to the implementation part of sending the MMS message in our Spring Microservice.  

Sending MMS

Implementations in Spring Microservice

To send the multimedia attachment, we first need to save the attachment to AWS S3 and then share the AWS S3 path and bucket name with the routing that sends the MMS. 

Below is the sample implementation in the Spring Microservice for sending the multimedia message.  

Java
 
@Override
public String sendMediaMessage(NotificationData notification) {
    String messageId = null;
    logger.info("SnsProviderImpl::sendMediaMessage - Inside send message with media");

    try {
        String localePreference = Optional.ofNullable(notification.getLocalePreference()).orElse("en-US");
        String originationNumber = "";

        if (StringUtils.hasText(fromPhone)) {
            JSONObject jsonObject = new JSONObject(fromPhone);
            if (jsonObject != null && jsonObject.has(localePreference)) {
                originationNumber = jsonObject.getString(localePreference);
            }
        }

        SendMediaMessageRequest request = SendMediaMessageRequest.builder()
                .destinationPhoneNumber(notification.getDestination())
                .originationIdentity(originationNumber)
                .mediaUrls(buildS3MediaUrls(notification.getAttachments()))
                .messageBody(notification.getMessage())
                .configurationSetName("pinpointsms_set1")
                .build();

        PinpointSmsVoiceV2Client pinpointSmsVoiceV2Client = getPinpointSmsVoiceV2Client();
        SendMediaMessageResponse resp = pinpointSmsVoiceV2Client.sendMediaMessage(request);

        messageId = resp != null && resp.sdkHttpResponse().isSuccessful() ? resp.messageId() : null;

    } catch (Exception ex) {
        logger.error("ProviderImpl::sendMediaMessage, an error occurred, detail error:", ex);
    }
    return messageId;
}


Here, the NotificationData object is the POJO, which contains all the required attributes for sending the message. It contains the destination number and the list of attachments that need to be sent; ideally, there would be only one attachment. The Attachment object contains the S3 path and the bucket name. Below is the implementation for buildS3MediaUrls. We need to send the S3 path and bucket name in a specific format, as shown in the below implementation, it has to be s3://{{bucketName}}/{{S3Path}}:

Java
 
public List<String> buildS3MediaUrls(List<Attachment> attachments) {
    List<String> urls = new ArrayList<>();
    for (Attachment attachment : attachments) {
        String url = String.format("s3://%s/%s",
                attachment.getAttachmentBucket(),
                attachment.getAttachmentFilePath());
        urls.add(url);
    }
    return urls;
}


Here is the definition for getPinpointSmsVoiceV2Client:

Java
 
protected PinpointSmsVoiceV2Client getPinpointSmsVoiceV2Client() {
    return PinpointSmsVoiceV2Client.builder()
            .credentialsProvider(DefaultCredentialsProvider.create())
            .region(Region.of(this.awsRegion)).build();
}


The messageId returned persists in our database and is used to track the message status further.

Types of Attachments

We can send various multimedia content using Pinpoint such as images, PDF files, audio, and video files. This enables us to cater to various business use cases, such as sending new product details, invoices, estimates, etc. Attachment size has certain limitations: a single MMS message cannot exceed 600KB in size for media files. We can send various types of content, including:

  • PDF - Portable Document Format
  • Image files like PDG, JPEG, GIF
  • Video/Audio - MP4, MOV

Limitations and Challenges

  1. AWS Pinpoint, with its scalable service, is a robust platform. However, it does have certain limitations, such as the attachment file size, which is capped at 600KB. This could pose a challenge when attempting to send high-resolution image files.
  2. Cost: Sending attachments for MMS is comparatively costlier than just sending SMS using AWS SNS. For MMS, the cost is $0.0195 (Base Price) + $0.0062 (Carrier Fee) = $0.0257 per message, while the cost for AWS SNS SMS is $0.00581 (Base Price) + $0.00302 (Carrier Fee) = $0.00883 per message. So, the MMS is three times costlier. AWS Pinpoint has a lot of messaging capabilities, including free messaging for specific types of messages like email, email, and push notifications. MMS is not part of the free tier.
  3. Tracking messages for end-to-end delivery can be challenging. Usually, with the AWS Lambda and CloudWatch combination, we should be able to track it end to end, but this requires additional setup.
  4. Opening attachments for different types of devices could be challenging. Network carriers could block files for specific types of content. 

Conclusion

AWS Pinpoint offers reliable, scalable services for sending multimedia messages. We can send various media types as long as we adhere to the file size limitation. Using Pinpoint, organizations can include multi-media messaging options as part of their overall communication strategy.

AWS Multimedia PDF SMS microservice

Opinions expressed by DZone contributors are their own.

Related

  • Leverage AWS Textract Service for Intelligent Invoice Processing in Account Payables Testing
  • How To Set up a Push Notification Service in 30 Minutes or Less
  • A Beginner’s Guide To Building Microservices With AWS Lambda
  • Microservices With Apache Camel and Quarkus (Part 4)

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!