Building a Notification Service with AWS Services

Kundan Kumar
3 min readMar 25, 2023

--

Image Reference

In this article, we will explore how to build a service that can send notifications as email, SMS, and push notifications and how to automate the sending of these notifications based on pre-defined system events.

Business Requirements

  1. Notification type: Notification can be send as email, sms and push notifications.
  2. Event Based and manual trigger:
    - The notifications should be automated, triggered by pre-defined system events, such as sending a welcome notification to the user after the registration process has been completed.
    - Notification should be send manual.
  3. Template Based: Notifications were template-based and could vary depending on the type of events or input.

Tech Stack

  1. Programming Language: JAVA, Python, Other languages
  2. AWS Services: Amazon Pinpoint, SQS, SES, SNS
  3. Database: Mongo DB
  4. Notification Types:
    Email: AWS SES
    SMS: AWS SNS
    Push Notification: FCM, APNs

Setup Prerequisites

I am assuming you have AWS account.

  1. Setup AWS Credential
  2. Create and configure a Amazon Pinpoint project
  3. Create Amazon Pinpoint message templates for each notification event with required notification channel.
  4. Create a collection in Mongo DB to store the notification events details. For example, we need to send email and sms notifications to the user after the registration complete, so create notification event for this event

notificationEvents:
{ “notificationEvent”: “userRegistered”, “notificationTypes”: [ {“type”: “email”, “pinpointTemplateName”: “user_registered”, “templateAttributes”: [“firstName”] }, {“type”: “sms”, “pinpointTemplateName”: “user_registered”, “templateAttributes”: [“firstName”] } ] }

Service Architecture

Notification Service Architecture

Notification Service Internal Work Flow

Architecture Overview

Event Consumer: This component responsible for the listens messages on the SQS queue and extracts the necessary information from the message. It then passes the information to the event handler.

Event Handler: This will contain the logic for sending notifications based on pre-defined events that are stored in MongoDB.

Notification Controller: This component will be responsible for handling incoming requests from the client. This will contain the necessary REST endpoints for sending notifications.

Repository Interface: This component will interact with the database to store and retrieve pre-defined events and settings.

Notification Service: This component will contain the business logic for sending notifications.

Notification Channel Service: This component is responsible for sending notifications to the appropriate channels, such as email, SMS, or push notifications. It will call the appropriate method from the Pinpoint client to send a specific type of notification.

Pinpoint Client: This component is responsible for interacting with the Amazon Pinpoint service to send notifications.

Conclusion

In this article, we have discussed how to build a service for sending notifications via email, SMS, and push notifications. We have used Amazon Pinpoint to send notifications, and we have used MongoDB to store pre-defined events and settings. With this microservice, you can easily add notification functionality to your application and provide a better user experience.

--

--

Kundan Kumar
Kundan Kumar

Written by Kundan Kumar

Passionate software engineer with a desire to learn and grow.

No responses yet