Improve Your Communication Technique: AWS Pinpoint – DZone – Uplaza

In immediately’s digital world, e mail is the go-to channel for efficient communication, with attachments containing flyers, pictures, PDF paperwork, and so on. Nonetheless, there could possibly be enterprise necessities for constructing a service for sending an SMS with an attachment as an MMS (Multimedia Messaging Service). This text delves into the best way to ship a number of media messages (MMS), their limitations, and implementation particulars utilizing the AWS Pinpoint cloud service.  

Setting Up AWS Pinpoint Service

Setting Up Cellphone Pool

Within the AWS console, we navigate to AWS Finish Consumer Messaging and arrange the Cellphone pool. The cellphone pool contains the cellphone numbers from which we’ll ship the message; these are the numbers from which the tip consumer will obtain the MMS message.  

Determine 1: AWS Finish Consumer Messaging

Determine 2: Cellphone Pool

We will add the origination numbers as soon as the cellphone pool has been created. The originating numbers are 10DLC (10-digit lengthy code). A2P (application-to-person) 10DLC is a technique companies use to ship direct textual content messages to prospects. It’s the new US-wide system and normal for corporations to speak with prospects through SMS or MMS messages. 

Configure Configuration Set for Pinpoint MMS Messages

After creating the cellphone pool, we create the configuration set required to ship the Pinpoint message. 

Determine 3: Configuration Set

Configuration units assist us log our messaging occasions, and we are able to configure the place to publish occasions by including occasion locations. In our case, we configure the vacation spot as CloudWatch and add all MMS occasions.

Determine 4: Configuration Set Occasion locations

Now that each one the conditions for sending MMS messages are full let’s transfer on to the implementation a part of sending the MMS message in our Spring Microservice.  

Sending MMS

Implementations in Spring Microservice

To ship the multimedia attachment, we first want to avoid wasting the attachment to AWS S3 after which share the AWS S3 path and bucket title with the routing that sends the MMS. 

Under is the pattern implementation within the Spring Microservice for sending the multimedia message.  

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

    attempt {
        String localePreference = Non-compulsory.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")
                .construct();

        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;
}

Right here, the NotificationData object is the POJO, which accommodates all of the required attributes for sending the message. It accommodates the vacation spot quantity and the record of attachments that should be despatched; ideally, there can be just one attachment. The Attachment object accommodates the S3 path and the bucket title. Under is the implementation for buildS3MediaUrls. We have to ship the S3 path and bucket title in a particular format, as proven within the under implementation, it needs to be s3://{{bucketName}}/{{S3Path}}:

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

Right here is the definition for getPinpointSmsVoiceV2Client:

protected PinpointSmsVoiceV2Client getPinpointSmsVoiceV2Client() {
    return PinpointSmsVoiceV2Client.builder()
            .credentialsProvider(DefaultCredentialsProvider.create())
            .area(Area.of(this.awsRegion)).construct();
}

The messageId returned persists in our database and is used to trace the message standing additional.

Forms of Attachments

We will ship numerous multimedia content material utilizing Pinpoint comparable to pictures, PDF information, audio, and video information. This allows us to cater to varied enterprise use instances, comparable to sending new product particulars, invoices, estimates, and so on. Attachment dimension has sure limitations: a single MMS message can not exceed 600KB in dimension for media information. We will ship numerous kinds of content material, together with:

  • PDF – Transportable Doc Format
  • Picture information like PDG, JPEG, GIF
  • Video/Audio – MP4, MOV

Limitations and Challenges

  1. AWS Pinpoint, with its scalable service, is a strong platform. Nonetheless, it does have sure limitations, such because the attachment file dimension, which is capped at 600KB. This might pose a problem when trying to ship high-resolution picture information.
  2. Value: Sending attachments for MMS is relatively costlier than simply sending SMS utilizing AWS SNS. For MMS, the fee is $0.0195 (Base Value) + $0.0062 (Service Price) = $0.0257 per message, whereas the fee for AWS SNS SMS is $0.00581 (Base Value) + $0.00302 (Service Price) = $0.00883 per message. So, the MMS is 3 times costlier. AWS Pinpoint has plenty of messaging capabilities, together with free messaging for particular kinds of messages like e mail, e mail, and push notifications. MMS will not be a part of the free tier.
  3. Monitoring messages for end-to-end supply may be difficult. Normally, with the AWS Lambda and CloudWatch mixture, we should always be capable of monitor it finish to finish, however this requires further setup.
  4. Opening attachments for several types of gadgets could possibly be difficult. Community carriers may block information for particular kinds of content material. 

Conclusion

AWS Pinpoint provides dependable, scalable providers for sending multimedia messages. We will ship numerous media sorts so long as we adhere to the file dimension limitation. Utilizing Pinpoint, organizations can embody multi-media messaging choices as a part of their general communication technique.

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version