<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: NotificationAPI</title>
    <description>The latest articles on Forem by NotificationAPI (@notificationapi).</description>
    <link>https://forem.com/notificationapi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F5611%2Fc987edaa-39e8-41f0-b9f9-c62d86273686.png</url>
      <title>Forem: NotificationAPI</title>
      <link>https://forem.com/notificationapi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/notificationapi"/>
    <language>en</language>
    <item>
      <title>4 Ways to Send Notifications to a Mobile Phone</title>
      <dc:creator>Dennis Kean</dc:creator>
      <pubDate>Wed, 22 May 2024 20:21:54 +0000</pubDate>
      <link>https://forem.com/notificationapi/4-ways-to-send-notifications-to-a-mobile-phone-3cp8</link>
      <guid>https://forem.com/notificationapi/4-ways-to-send-notifications-to-a-mobile-phone-3cp8</guid>
      <description>&lt;p&gt;If you are building a notification service for your product and wondering how to send notifications to your users via their smartphones, we will discuss 4 solutions for sending mobile notifications.&lt;/p&gt;

&lt;p&gt;For a brief overview, here is a table including quick comparison points for our given solutions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;SMS&lt;/th&gt;
&lt;th&gt;Mobile Push&lt;/th&gt;
&lt;th&gt;Web Push&lt;/th&gt;
&lt;th&gt;3rd-Party Social Apps&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Most expensive option&lt;/td&gt;
&lt;td&gt;One-time cost for app store listing&lt;/td&gt;
&lt;td&gt;No cost&lt;/td&gt;
&lt;td&gt;No cost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Time&lt;/td&gt;
&lt;td&gt;~Weeks of compliance approvals&lt;/td&gt;
&lt;td&gt;~Days of app development + approval time&lt;/td&gt;
&lt;td&gt;~Hours, no 3rd-parties&lt;/td&gt;
&lt;td&gt;~Days to integrate 3rd-parties&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User Experience&lt;/td&gt;
&lt;td&gt;Simple, fast and direct&lt;/td&gt;
&lt;td&gt;Must download app, flexible design&lt;/td&gt;
&lt;td&gt;Must opt-in, rigid UI&lt;/td&gt;
&lt;td&gt;Easy to use, rigid UI&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  SMS
&lt;/h2&gt;

&lt;p&gt;SMS is a direct way to send notifications to others. Accessible through 3rd-party services, you can integrate notifications via text messages into any project. This will require the designated user’s mobile number, and setting up a plan with services capable of SMS communications such as &lt;a href="https://www.notificationapi.com/features/sms-call-notifications"&gt;NotificationAPI&lt;/a&gt;, Twilio, etc.  &lt;/p&gt;

&lt;p&gt;Some drawbacks to consider when approaching SMS notifications are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Making sure notifications feel important&lt;/li&gt;
&lt;li&gt;Requires users to trust you with mobile numbers&lt;/li&gt;
&lt;li&gt;At large volumes, it will be costly&lt;/li&gt;
&lt;li&gt;Notifications must follow 10DLC compliances &amp;amp; regulations (NotificationAPI handles these for you)
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Mobile Push
&lt;/h2&gt;

&lt;p&gt;Mobile Push offers a great way to deliver notifications to your audience. Through your app, users can opt-in to notifications without divulging personal phone numbers. If your service is already app or mobile-oriented, getting users to opt-in for updates should have a higher conversion rate than projects or services that don’t rely on mobile at all. &lt;/p&gt;

&lt;p&gt;While Mobile Push notifications may sound ideal, developers who haven’t already published an app can find this approach costly and drawn out - here’s why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developing an app for Apple and Google’s app stores&lt;/li&gt;
&lt;li&gt;Sending push notifications requires creating and managing device tokens (NotificationAPI handles this for you)&lt;/li&gt;
&lt;li&gt;Having a mobile app creates expectations of other app functionalities from your end-users
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Web Push
&lt;/h2&gt;

&lt;p&gt;Web Push might be the most approachable method for those looking to build their own notification system. Its straightforward design lets users create basic notifications either on their own or through integrating 3rd-party services. Developers can skip building an app or purchasing an SMS service plan, saving both time and money. Users can opt-in by simply visiting your website on their phone and allowing Push notifications when prompted. These web push notifications look similar to app notifications but offer less flexibility and options.&lt;/p&gt;

&lt;p&gt;Web Push is a viable solution for mobile notifications, however, there are some minor cons worth mentioning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This requires your users to first visit your website and allow Push Notifications&lt;/li&gt;
&lt;li&gt;You need to generate device tokens in your front-end and store them in the back-end (NotificationAPI does this for you)&lt;/li&gt;
&lt;li&gt;These notifications are easily dismissed and forgotten without a dedicated inbox (NotificationAPI offers an in-app notification inbox)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Other Social Apps (Slack, WhatsApp, Telegram)
&lt;/h2&gt;

&lt;p&gt;Using 3rd-party communication apps allows for free integration of notifications through apps your users may already use. These apps are already well optimized for user experience so they look and feel good to use.&lt;/p&gt;

&lt;p&gt;Having great UX at no cost are good enough reasons to consider 3rd-party apps for notifications, though there are still some downsides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For apps like Slack, it takes time to develop and integrate your server/channel&lt;/li&gt;
&lt;li&gt;Similar to Mobile Push, using 3rd-party apps generates the expectation of more than just notifications
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Picking the right approach depends a lot on the platforms your company aims to support. For example, if your software is only going to be accessible through a web interface, then SMS and Web Push Notifications are viable options. If you have plans for a mobile app, then mobile app notifications are certainly the right way to go. If you believe most of your users will integrate your software into existing apps, then you may want to consider the last option.&lt;/p&gt;

</description>
      <category>saas</category>
      <category>notifications</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Ultimate Guide on Notification Services - A Technical Overview (2024)</title>
      <dc:creator>Dennis Kean</dc:creator>
      <pubDate>Wed, 01 May 2024 20:34:30 +0000</pubDate>
      <link>https://forem.com/notificationapi/ultimate-guide-on-notification-services-a-technical-overview-2024-57c9</link>
      <guid>https://forem.com/notificationapi/ultimate-guide-on-notification-services-a-technical-overview-2024-57c9</guid>
      <description>&lt;p&gt;Do you need a 3rd-party notification service? In this article, we review the challenges of a typical notification project and review the viable solutions.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;Until a few years ago, the only way to build product-to-user notifications in SaaS products was to build them from scratch. This came with a few problems.  &lt;/p&gt;

&lt;h2&gt;
  
  
  The business case against building notifications
&lt;/h2&gt;

&lt;p&gt;If you have ever tried to prioritize a notification project in a growing tech company, you have experienced the following:&lt;/p&gt;

&lt;p&gt;Similar to Authentication, notifications are "utility" features. They don't generate revenue, don't have a place on your pricing page, or excite end-users. So it's difficult to get buy-in from your team to prioritize notifications. However, they are &lt;strong&gt;necessary&lt;/strong&gt; for users, and when implemented poorly - just like authentication - they blow up in your face with bugs, downtimes, frustrated users (&lt;a href="https://status.launchdarkly.com/incidents/fsvv39rnqcd5?u=t3w02q1rgp4n"&gt;LaunchDarkly&lt;/a&gt;, &lt;a href="https://www.businessinsider.com/starbucks-app-glitch-sends-order-ready-error-message-outage-2023-7"&gt;Starbucks&lt;/a&gt;), and poor DX.&lt;/p&gt;

&lt;p&gt;Generally, after a few important clients request notifications or some bad reviews on G2Crowd, notifications make it to your roadmap.  &lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with building notifications
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;There is nothing technically complicated about building notifications.&lt;/strong&gt; It's just that there is so much &lt;strong&gt;nuance&lt;/strong&gt; and &lt;strong&gt;gotchas&lt;/strong&gt; that most people don't think about. Some of these are technical considerations, and some are more relevant to UX:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;General considerations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Integrating to a 3rd-party, e.g. email, Slack, WebSocket&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Respecting the 3rd-party API Rate Limits, implementing job queues and retry mechanisms, e.g. &lt;a href="https://docs.sendgrid.com/v2-api/using_the_web_api#:~:text=Rate%20Limits,%E2%80%9Ctoo%20many%20requests%E2%80%9D%20message."&gt;SendGrid&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Implementing user preferences and opt-outs (&lt;a href="https://www.notificationapi.com/blog/how-to-prevent-aws-ses-review-and-suspension"&gt;why is this important?&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Email specific considerations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Monitoring bounces/reports/complaints to &lt;a href="https://www.notificationapi.com/blog/how-to-prevent-aws-ses-review-and-suspension"&gt;avoid being suspended&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Account/Company verification and higher API limit requests - &lt;a href="https://www.reddit.com/r/SendGrid/comments/14jgn23/denied_signup_instantly_for_violating_acceptable/"&gt;example stories&lt;/a&gt;   &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Designing and coding HTML email templates&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Batching, e.g. weekly digests, and all of its necessary infrastructure (database, cron, job runner)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Google bulk email sender requirements (&lt;a href="https://www.notificationapi.com/blog/the-developers-guide-to-google-bulk-sender-requirements"&gt;learn more&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In-App specific considerations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Database, REST APIs, and optionally WebSocket&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In-App inbox UI&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;UI-side batching, e.g. "You have 10 new comments" vs. ten separate "You have a comment" notifications&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SMS/Calls:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Brand/Campaign approval (&lt;a href="https://help.twilio.com/articles/1260800720410-What-is-A2P-10DLC"&gt;A2P 10DLC Registration&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Country-specific regulations and registrations And more... I know what you are thinking:  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Do I actually need all this complexity?
&lt;/h2&gt;

&lt;p&gt;TLDR: Are these notifications part of a growing software where people rely on them? Then, the answer is yes.&lt;/p&gt;

&lt;p&gt;You fall in this category if you are building a production-grade SaaS product or internal automation where notifications are an important part of the workflow, e.g. scheduling, review and approval, collaboration, communication, monitoring, or alerting. This means your notification requirements are already complicated or are going to grow in complexity as your business and client base grow.&lt;/p&gt;

&lt;p&gt;If you don't fall into this category, you can safely close this tab, code something together, and move onto more important things in life.&lt;/p&gt;

&lt;p&gt;If you fall in this category, let's learn more about:  &lt;/p&gt;

&lt;h2&gt;
  
  
  Notification Services
&lt;/h2&gt;

&lt;p&gt;Definition: A notification service facilitates implementing, sending, and monitoring product-to-user notifications. It consists of tools and APIs to design notifications, configure workflows, manage user preferences, deliver to the inbox, logging, and analytics. It could be a 3rd-party Notification-as-a-Service like &lt;a href="https://www.notificationapi.com"&gt;NotificationAPI&lt;/a&gt; or implemented internally as a microservice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How about marketing notifications?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's differentiate between:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Product&lt;/strong&gt;: (or product-to-user) notifications, which this article is mainly about, are generated from the codebase and are specific to a user or a client. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Promotional&lt;/strong&gt;: announcements or engagement baits that are always sent to all or many users at once. They don't need to be initiated from the codebase.&lt;/p&gt;

&lt;p&gt;These two categories of notifications have different triggers (product vs. business) and goals, and are managed by different teams. &lt;strong&gt;Avoid combining them into the same system. Use a CRM for promotional notifications. Build or buy a notification service for product notifications.&lt;/strong&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Build vs Buy
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Fun backstory:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In a different life where I was the CTO of a growing VC-backed B2B SaaS company, our notification system was the bane of our existence. The notification database would frequently fail to scale with our users and cause outages; nobody was happy with the notification UX, users complained in G2Crowd reviews. Even developers were not happy with the DX and everyone wanted to replace it. "There must be a 3rd-party for this", so I googled the words "Notification API" and found nothing. Am I missing something here? Isn't this a big enough problem? I queried our task management software and found that notifications made up 5% of our whole &lt;strong&gt;Done&lt;/strong&gt; tasks. We had spent 5% of our WHOLE productivity on something that had to be replaced. Having found no proper solution, NotificationAPI was born a few years later.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We haven't done a formal study, but here are some anecdotes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Speaking to CTOs, architects and PMs who are considering NotificationAPI instead of building from scratch, they generally foresee their in-house project to take &lt;strong&gt;4-8 weeks&lt;/strong&gt;, at about &lt;strong&gt;half the cost&lt;/strong&gt; of NotificationAPI in infrastructure and 3rd-party tools&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Speaking to our customers who adopt NotificationAPI [&lt;a href="https://www.notificationapi.com/blog/how-songflow-helps-songwriters-stay-in-sync-using-notificationapi"&gt;1&lt;/a&gt;, &lt;a href="https://www.notificationapi.com/blog/customer-interview-adopting-a-notification-service-at-milk-moovement"&gt;2&lt;/a&gt;], they tell us that we have saved them weeks to &lt;strong&gt;months of work&lt;/strong&gt;, in line with the above estimation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Talking to some CTOs who already have an in-house notification system in place, it seems like &lt;strong&gt;5%&lt;/strong&gt; is a good estimation of the engineering effort they put into maintaining their notification system (1 in 20 tasks)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So in summary and based on anecdotal experience:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Build&lt;/th&gt;
&lt;th&gt;Buy with NotificationAPI&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Upfront Engineering Cost&lt;/td&gt;
&lt;td&gt;Weeks to Months&lt;/td&gt;
&lt;td&gt;Days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;50% less&lt;/td&gt;
&lt;td&gt;&lt;a href="https://www.notificationapi.com/pricing"&gt;Check our Pricing&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upkeep&lt;/td&gt;
&lt;td&gt;5% of your engineering capacity over time&lt;/td&gt;
&lt;td&gt;~0%, Most tasks can be handed off to CS/Design&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Requirements to think about
&lt;/h2&gt;

&lt;p&gt;Whether you are building or buying a Notification Service, think about the following requirements:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functional:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Supported Channels &amp;amp; Platforms&lt;/strong&gt;, e.g. Email, In-App (bell), Mobile Push, Web Push, SMS, Automated Calls, Slack/Teams, Desktop&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Batching/Digest&lt;/strong&gt; to avoid frustrating users with notification overload&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User Preferences&lt;/strong&gt; to let end-users decide how and what they receive&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Visual Editors&lt;/strong&gt; to let your designers/CS teams build the notifications&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logs&lt;/strong&gt; for your CS team to find sent notifications and figure out why a user hasn't received a notification&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Analytics/Reporting&lt;/strong&gt; for your PMs to improve the notification experience&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;If everything is important, then nothing is important. Too many notifications for a user is equal to having no notifications at all. No user is going to scroll through 50 notifications. That's why batching, digest and user preferences are very important in a busy application.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Technical:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Language or framework-specific SKDs&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pre-built UI components&lt;/strong&gt; for in-app notifications (the bell icon), notification preferences pages, unsub pages&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Retention:&lt;/strong&gt; How long are notifications and logs stored?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Consider your peak time output and their&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Availability&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compliance&lt;/strong&gt; (SOC2, GDPR, HIPAA)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Migration:&lt;/strong&gt; How are you moving all the user preferences and existing in-app notifications to a new service?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Implementation Options
&lt;/h2&gt;

&lt;p&gt;Below are all the options we could think of in order of taking the least amount of effort &amp;amp; risk to the most:&lt;/p&gt;

&lt;h3&gt;
  
  
  1) NotificationAPI
&lt;/h3&gt;

&lt;p&gt;We built &lt;a href="https://www.notificationapi.com"&gt;NotificationAPI&lt;/a&gt; to plug into your software as your own product-to-user notification system. We believe it's a good fit for growing B2B SaaS products with multiple types of notifications. It does the following for you:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Designing Notifications:&lt;/strong&gt; pre-built UI components, visual template editors&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simple Implementation:&lt;/strong&gt; comes with user preferences, batching &amp;amp; digest, and other logic &amp;amp; databases you would normally implement yourself&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Delivery:&lt;/strong&gt; actually delivers the notification to the destination without requiring any other 3rd-parties (with the exception of mobile push which Google/Apple have a monopoly over)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Post-Release:&lt;/strong&gt; customer success tools, logs, and analytics&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pros: low effort, low risk, UX, DX&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt; &lt;a href="https://www.notificationapi.com/pricing"&gt;&lt;strong&gt;cost&lt;/strong&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h3&gt;
  
  
  2) Notification Infrastructure
&lt;/h3&gt;

&lt;p&gt;Think AWS SNS paired with AWS Step Functions or any glorified rebranded versions of them. They help with some of the challenges, but they don't address the majority of the project: notification design, delivery, rate limiting, user preferences, notification batching, monitoring, etc. We believe this middle-ground inherits the problems of both build and buy options without much to offer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros: control&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons: cost, effort, stack fragmentation&lt;/strong&gt;  &lt;/p&gt;

&lt;h3&gt;
  
  
  3) Building from Scratch
&lt;/h3&gt;

&lt;p&gt;Viable option depending on your tolerance for the effort and time. We have written a few articles that might help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.notificationapi.com/blog/notification-service-design-with-architectural-diagrams"&gt;Notification service architecture design&lt;/a&gt; (Serverless version &lt;a href="https://www.notificationapi.com/blog/serverless-notification-service-design-in-aws"&gt;here&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.notificationapi.com/blog/top-non-technical-mistakes-with-your-notification-service"&gt;Common non-technical mistakes with building a notification system&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.notificationapi.com/blog/building-a-notification-service-top-technical-mistakes"&gt;Common technical mistakes&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.notificationapi.com/blog/hidden-scalability-bottlenecks-in-user-notifications"&gt;Hidden scalability bottle-necks with notifications&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pros: cost, control&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons: effort, DX&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  TLDR
&lt;/h3&gt;

&lt;p&gt;Consider a notification service if your notifications are part of a &lt;strong&gt;growing&lt;/strong&gt; software (B2B SaaS, important business automation) where people &lt;strong&gt;rely&lt;/strong&gt; on them (collaboration, communication, alerting, monitoring, approvals, reviews). Otherwise, just roll your own.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Developer's Guide to Google Bulk Sender Requirements</title>
      <dc:creator>Sahand Seifi</dc:creator>
      <pubDate>Mon, 05 Feb 2024 17:47:20 +0000</pubDate>
      <link>https://forem.com/notificationapi/the-developers-guide-to-google-bulk-sender-requirements-826</link>
      <guid>https://forem.com/notificationapi/the-developers-guide-to-google-bulk-sender-requirements-826</guid>
      <description>&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;Starting in February 2024, Google enforces new requirements for sending emails to its users.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Does this apply to me?
&lt;/h2&gt;

&lt;p&gt;Yes. The requirements can be split into 3 levels:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Basic requirements for any sender&lt;/li&gt;
&lt;li&gt;Bolder new requirements for domains that send more than 5000 emails per day&lt;/li&gt;
&lt;li&gt;One additional requirement for domains that send marketing emails&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Since it is unclear how Google recognizes your emails as transactional vs. marketing, we recommend that anyone sending more than 5k emails/day follow all the requirements.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Do NotificationAPI users need to take action?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.notificationapi.com"&gt;NotificationAPI&lt;/a&gt; users are automatically compliant.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Level 1 Requirements:
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Any Sender
&lt;/h2&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h3&gt;
  
  
  1. SPF &amp;amp; DKIM
&lt;/h3&gt;

&lt;p&gt;You probably have one or both of these DNS records already setup:&lt;/p&gt;

&lt;p&gt;AWS SES: Verified domains use DKIM by default, you may need to verify SPF&lt;br&gt;
SendGrid: DKIM &amp;amp; SPF verified by default&lt;br&gt;
Mailgun: you need to check the "DKIM" option when configuring your domain&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to test:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Send an email to yourself in Gmail. Check your domain's verifications using the "Show Original" option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg8eot346ghohxokqu5iz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg8eot346ghohxokqu5iz.png" alt="Test SPF/DKIM/DMARC verification in Google&amp;lt;br&amp;gt;
" width="800" height="440"&gt;&lt;/a&gt;&lt;br&gt;
‍&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Spam rate &amp;lt; 0.1% - 0.3%
&lt;/h3&gt;

&lt;p&gt;This refers to how many of your outgoing emails are reported as spam by recipients. Google suggests keeping this below 0.1% (1 in 1000 emails) and avoiding 0.3%.&lt;/p&gt;

&lt;p&gt;We recommend signing up for &lt;a href="https://postmaster.google.com/"&gt;Google Postmaster Tools&lt;/a&gt;, which reports on your domain's email reputation and spam rates.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Generic requirements: PTR Record, TLS Connection, RFC 5322 Email Formatting
&lt;/h3&gt;

&lt;p&gt;If you use any modern email service, you shouldn't worry about these requirements.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Level 2 Requirements:
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Senders with 5000+ emails/day
&lt;/h2&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h3&gt;
  
  
  4. DMARC record
&lt;/h3&gt;

&lt;p&gt;‍DMARC is a TXT record that has many configurations. Simply, it tells recipients how to treat emails from your domain that don't pass SPF/DKIM verification.&lt;/p&gt;

&lt;p&gt;Setting a strict DMARC configuration could block your emails. So be careful!&lt;/p&gt;

&lt;p&gt;We recommend that you start with a loose DMARC record, such as:&lt;/p&gt;

&lt;p&gt;Record Name: _dmarc&lt;/p&gt;

&lt;p&gt;‍Record Value: v=DMARC1; p=none;&lt;/p&gt;

&lt;p&gt;This record tells recipients that you want to follow DMARC standard v1 (recommended) but not to do anything (p=none) when they encounter an email from your domain that doesn't pass SPF/DKIM.&lt;/p&gt;

&lt;p&gt;Over time, you want to change the DMARC record to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Report back emails with faulty SPF/DKIM using the rua option,&lt;/li&gt;
&lt;li&gt;Fix the issues,&lt;/li&gt;
&lt;li&gt;And make the DMARC record more strict using the p option&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h3&gt;
  
  
  5. DMARC Alignment‍
&lt;/h3&gt;

&lt;p&gt;There are two "from" addresses for every email:&lt;/p&gt;

&lt;p&gt;Header From: the regular From address you see on an email, e.g. John Smith &lt;a href="mailto:john@smith.com"&gt;john@smith.com&lt;/a&gt;&lt;br&gt;
Envelope From: refers to the source of the email. For example, an email from &lt;a href="mailto:john@smith.com"&gt;john@smith.com&lt;/a&gt; may have an envelope header sendegrid.com.&lt;br&gt;
DMARC Alignment means Header From matching your Envelope From.&lt;/p&gt;

&lt;p&gt;Alignment could be 1) relaxed, where one From is the subdomain of the other from, or 2) strict, where the domains exactly match. Google is ok with either.&lt;/p&gt;

&lt;p&gt;In the image below, you see a spam email where the Header From differs from the Envelope From, and Gmail is bringing attention to it with the "via" keyword.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqra8edcy76sx1j9dg89.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqra8edcy76sx1j9dg89.png" alt="Gmail highlighting the difference of Header From and Envelope From" width="800" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Level 3 Requirements:
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Marketing emails
&lt;/h2&gt;

&lt;p&gt;Recommended for Transactional Too!&lt;br&gt;
There is no way to know how Google categorizes your emails (marketing vs transactional), so we recommend doing this anyway.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h3&gt;
  
  
  6. One-Click Unsubscribe
&lt;/h3&gt;

&lt;p&gt;First, create an API end-point like the one below. The method must be POST, but the URL can be anything.&lt;/p&gt;

&lt;p&gt;Method: POST&lt;br&gt;
URL: &lt;a href="https://app.yourdomain.com/unsubscribe?email=user@gmail.com"&gt;https://app.yourdomain.com/unsubscribe?email=user@gmail.com&lt;/a&gt;&lt;br&gt;
Body: none&lt;br&gt;
You should unsubscribe the user from your email when this end-point is hit. For example, Google will call this end-point when the user hits the "Unsubscribe" button in Gmail's interface.&lt;/p&gt;

&lt;p&gt;The One-Click Unsubscribe mechanism in action&lt;br&gt;
Then, add the following headers to your outgoing emails:&lt;/p&gt;

&lt;p&gt;List-Unsubscribe-Post: List-Unsubscribe=One-Click&lt;br&gt;
List-Unsubscribe: &lt;a href="https://app.yourdomain.com/unsubscribe?email=user@gmail.com"&gt;https://app.yourdomain.com/unsubscribe?email=user@gmail.com&lt;/a&gt;&lt;br&gt;
Remember to replace it with actual values.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Compliance through NotificationAPI
&lt;/h2&gt;

&lt;p&gt;NotificationAPI provides the one-click unsubscribe option at no cost without writing a single line of code. Our account setup process also ensures your emails comply with SPF, DKIM, DMARC, and DMARC Alignment.&lt;/p&gt;

&lt;p&gt;So, all NotificationAPI users are compliant without additional effort.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Let us know what you think
&lt;/h2&gt;

&lt;p&gt;Do you have any questions or did we miss anything? Ping us on our &lt;a href="https://www.notificationapi.com/contact"&gt;contact page&lt;/a&gt;, and we'll send you some goodies for your contribution!&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://support.google.com/a/answer/81126?hl=en"&gt;High-Level Google Requirements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://support.google.com/a/answer/10032169?sjid=2442999713009550434-NC"&gt;More on DMARC from Google&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Serverless Notification Service Design in AWS - with diagrams</title>
      <dc:creator>Sahand Seifi</dc:creator>
      <pubDate>Mon, 17 Oct 2022 14:12:42 +0000</pubDate>
      <link>https://forem.com/notificationapi/serverless-notification-service-design-in-aws-with-diagrams-5h42</link>
      <guid>https://forem.com/notificationapi/serverless-notification-service-design-in-aws-with-diagrams-5h42</guid>
      <description>&lt;h2&gt;
  
  
  Background and Motivation
&lt;/h2&gt;

&lt;p&gt;We discussed why some software development teams consider an internal or external notification service in our &lt;a href="https://www.notificationapi.com/blog/ultimate-guide-on-notification-services"&gt;Ultimate Guide to Notification Services&lt;/a&gt;, including reasons such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complexity of notifications (number of channels, number of notifications) demanding a service-oriented approach&lt;/li&gt;
&lt;li&gt;Reliability and scalability&lt;/li&gt;
&lt;li&gt;Creating internal tools for observability and monitoring&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We also proposed a generic &lt;a href="https://www.notificationapi.com/blog/notification-service-design-with-architectural-diagrams"&gt;Notification Service Design&lt;/a&gt; compatible with any cloud provider, with critical technical constraints and business requirements. This article proposes a Serverless design for a notification microservice with AWS services, given the same objectives mentioned in the previous article.&lt;/p&gt;

&lt;h2&gt;
  
  
  High-Level Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tp82gs5Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hndfpup6i9edza1mbyyx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tp82gs5Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hndfpup6i9edza1mbyyx.png" alt="High Level Serverless Notification Service Design" width="880" height="987"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step-by-Step Architecture:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. POST /send
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The /send end-point is a Lambda function with AWS's new &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html"&gt;Function URL&lt;/a&gt; capability.&lt;/li&gt;
&lt;li&gt;The Function URL authorizes the incoming requests based on the IAM_ROLE of the caller. This allows you to skip API Gateway or write any authorization code. So, for example:

&lt;ul&gt;
&lt;li&gt;Your code runs on EC2 &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html"&gt;with a specific IAM Role&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html"&gt;modify the policy on your EC2 role &lt;/a&gt;to allow invoking the /send end-point from your code&lt;/li&gt;
&lt;li&gt;When making an API call to /send from your code, you follow this article &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/urls-invocation.html"&gt;to sign your requests&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;The request to this end-point contains the userId of the user. This allows the service that sends the notification has no knowledge of your user's attributes.&lt;/li&gt;
&lt;li&gt;The request also contains a notificationId, which indicates the type of notification, such as alert or new_customer.&lt;/li&gt;
&lt;li&gt;The request to this end-point also contains all the channels the service wishes to send. These channels will get filtered in the next step based on user preferences.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Match Notification Preferences
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A DynamoDB stores records that indicate whether user should receive a specific notification on a specific channel. Record structure: KEY: user_id:notification_id, VALUE: [{channel: "email", state: true}, {channel: "sms", state: false}]‍&lt;/li&gt;
&lt;li&gt;If the send end-point reads a "false" value from the records, it will ignore that channel. If a record for a channel does not exist, it means the user has not explicitly set their preferences. In this case, you need to agree to a default.&lt;/li&gt;
&lt;li&gt;Notice how we allow users to update the data in this table directly. How does this work? You can allow your front-end to directly update records in a DynamoDB with &lt;a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/specifying-conditions.html"&gt;Fine-Grained IAM Policy for DynamoDB&lt;/a&gt;. For example, you only allow users to update records if the KEY contains their userId.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Get User Attributes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The /send end-point read the user's email address, phone number, ... from the Cognito User Pool.&lt;/li&gt;
&lt;li&gt;Notice that you can only make Cognito's getUser() request &lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/limits.html"&gt;120 times per second&lt;/a&gt;. If you wish to send at higher scales, you may store this information in a DynamoDB.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Publish to Fanout
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The /send end-point forms a message similar to the image above (top-right) and sends it to SNS, only containing channels that the user is subscribed to.&lt;/li&gt;
&lt;li&gt;The SNS is configured to fanout this message to multiple queues.&lt;/li&gt;
&lt;li&gt;However, SNS is configured to filter destinations based on the list of channels in the message.
Example:

&lt;ul&gt;
&lt;li&gt;The caller requests sending a notification using email and SMS&lt;/li&gt;
&lt;li&gt;The /send end-point decides that the user is not subscribed to SMS using the DynamoDB, so it only includes the email data in the SNS message&lt;/li&gt;
&lt;li&gt;SNS looks at the channels in the message and only duplicates the message to the email queue&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Fanout to Job Processors
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The messages go into SQS queues until they are processed.&lt;/li&gt;
&lt;li&gt;You can configure complicated or straightforward failure and retry mechanisms at this stage.&lt;/li&gt;
&lt;li&gt;We recommend setting the retry to 1. We also recommend setting up a DLQ with a 24-hour time-to-live (TTL) window. It will hold onto failed messages to reroute them later when issues are resolved.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Process Delivery Jobs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;These are simple Lambda functions that take the message from the queue and send it to the appropriate service. For example, the email sender lambda would read the message and send it to SendGrid or a similar service.&lt;/li&gt;
&lt;li&gt;You can limit the number of concurrent lambdas to avoid sending too many emails or SMS and getting throttled.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Further Improvements
&lt;/h2&gt;

&lt;p&gt;Here are a few things that are possible but we haven't covered. If you need any of these capabilities, read the next section.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In-App Notifications: They are complex. They require tables, APIs, and UIs&lt;/li&gt;
&lt;li&gt;Centralizing the notification UI elements and providing a visual editor on it&lt;/li&gt;
&lt;li&gt;Feature flags for notifications&lt;/li&gt;
&lt;li&gt;Monitoring and reporting&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  An external Notification-as-a-Service
&lt;/h2&gt;

&lt;p&gt;Building an internal notification service is a lot of (annoying) work. We know because we have built this a few times in our careers.&lt;/p&gt;

&lt;p&gt;That is why we made &lt;a href="https://www.notificationapi.com"&gt;NotificationAPI&lt;/a&gt;: a plug-and-play notification-as-a-service solution. It takes 10 minutes to configure and integrate and gives you much more functionality, including in-app notifications, feature flags, and logs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If I had to describe NotificationAPI in one word, it would be simple!&lt;br&gt;
-- Jacob Brown, Software Team Lead&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://www.notificationapi.com/blog/customer-interview-adopting-a-notification-service-at-milk-moovement"&gt;Watch Jacob's interview&lt;/a&gt;, discussing how they implemented their own notifications, then switch to NotificationAPI.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Notification Service Design - with diagrams</title>
      <dc:creator>Sahand Seifi</dc:creator>
      <pubDate>Mon, 09 May 2022 14:38:12 +0000</pubDate>
      <link>https://forem.com/notificationapi/notification-service-design-with-diagrams-2c77</link>
      <guid>https://forem.com/notificationapi/notification-service-design-with-diagrams-2c77</guid>
      <description>&lt;p&gt;In our &lt;a href="https://www.notificationapi.com/blog/ultimate-guide-on-notification-services" rel="noopener noreferrer"&gt;Ultimate Guide on Notification Services&lt;/a&gt;, we discussed if and when you should build a Notification Service. This article proposes a notification system architecture that you can use as your in-house notification system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;Notifications are a common culprit for code smells, technical debt, and endless HTML/CSS templates lying around your code-base. They usually end up with no tests, no oversight or ownership, and cause pains such as repeated notifications or banned email accounts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Objective
&lt;/h2&gt;

&lt;p&gt;To design a notification service that can send product-to-user notifications across many channels at scale&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Send API: Expose an authenticated end-point so we can trigger sending notifications from any back-end and microservice&lt;/li&gt;
&lt;li&gt;Supported Channels: Support sending notifications to any channel that exposes an API, e.g., Email, SMS, Push&lt;/li&gt;
&lt;li&gt;User Preferences: Allow users to pick their user preferences on each notification and channel&lt;/li&gt;
&lt;li&gt;Respecting downstream service limits: Avoid getting throttled or suspended by your email or SMS service&lt;/li&gt;
&lt;li&gt;Scalable: Allow horizontal scaling for (theoretically) unlimited scaling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  High-Level Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9dct0i72n6xpugwlauf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9dct0i72n6xpugwlauf.png" alt="Notification Service Architecture Diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  A Quick Overview
&lt;/h2&gt;

&lt;p&gt;Let's imagine that your code should send a notification. The numbers below correspond with the numbers you see on the diagram.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your code calls the POST /send endpoint. The request contains the userId of the recipient, the type of the notification, and the contents of the notification for every supported channel.&lt;/li&gt;
&lt;li&gt;The /send end-point authenticates the request using &lt;a href="https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow" rel="noopener noreferrer"&gt;OAuth2's Client Credentials Flow&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;It then requests the user's notification preferences from the database. The preferences indicate whether the user is subscribed to a particular notification and channel or not.&lt;/li&gt;
&lt;li&gt;It will then read the user attributes such as email address or phone number from the database.&lt;/li&gt;
&lt;li&gt;This end-point will form a message object containing user attributes from step (4) along with the channels and content for each channel. However, it will exclude disabled channels based on step (3). Finally, the message is sent to a fan out service.&lt;/li&gt;
&lt;li&gt;The fanout service is configured to broadcast incoming messages to job queues. However, there is filtering in place to ignore job queues related to channels that are not listed inside the message.&lt;/li&gt;
&lt;li&gt;There is a job queue and processor per channel. The processor picks up the job and requests the appropriate service, e.g., a transactional email or SMS service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Important Architecture Decisions:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  POST /sent
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You notice that the request to this end-point only contains the userId and not the email or phone number. This allows the services that send notifications have no knowledge of your users.&lt;/li&gt;
&lt;li&gt;The end-point is behind a load balancer to ensure scalability.&lt;/li&gt;
&lt;li&gt;The end-point is not protected with your regular user-facing authentication. Since the service that makes the request is a "program" itself, you need to use a different authentication mechanism known as the OAuth2 Client Credentials Flow used for server-to-server communication. Here are links to how to do this in &lt;a href="https://auth0.com/docs/get-started/architecture-scenarios/server-application-api" rel="noopener noreferrer"&gt;Auth0&lt;/a&gt; and &lt;a href="https://lobster1234.github.io/2018/05/31/server-to-server-auth-with-amazon-cognito/" rel="noopener noreferrer"&gt;Cognito&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Do we need a whole end-point for this?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;There will be many parts of your application that will be issuing notifications. Implementing the send function as an end-point behind a load-balancer ensures that it is independently scalable and allows you to use it from virtually anywhere, e.g., from a new codebase or your build pipeline.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h3&gt;
  
  
  User Preferences
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use a highly scalable NoSQL or key/value pair database. Structure the records as: KEY: &lt;/li&gt;
&lt;li&gt;sample_user_id:sample_notification_id, VALUE: [{channel: "email", state: true}, {channel: "sms", state: false}]‍&lt;/li&gt;
&lt;li&gt;When the send end-point sees "false" values in the records, it will remove the related channel from the message sent to the fanout. If a record for a channel does not exist, it means the user has not explicitly set their preferences. In this case, you need to agree to a default.&lt;/li&gt;
&lt;li&gt;The information in the user_preferences table is updated by the user through your UI, through a normal end-point protected by your common authentication mechanisms.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Why do we need user preferences?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Not allowing users to control their notification preferences will only frustrate them and force them to mark your notifications as spam or mute your notifications. This will further damage your user experience and mark your account for suspension by email or SMS delivery services.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h3&gt;
  
  
  Fan Out
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fanout takes a message and duplicates it to various places. They are cheap and highly scalable. In AWS, use SNS. In Google Cloud Platform, use Pub/Sub, and in Azure, use topics and subscriptions.&lt;/li&gt;
&lt;li&gt;You can configure filtering between the fanout and job queues to avoid sending unnecessary messages to job queues of channels that have been excluded. For example, in AWS SNS, you can specify that the email job queue should only receive the fanout message if the message contains the "email" property inside the "channels" property.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Why do we need a fanout?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;You could write code that puts the same message into the necessary job queues, but fanout is cheaper, and writing less code is good. Another benefit of fanout is being able to easily add/remove queues, thus allowing you to refactor and extend your channels.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h3&gt;
  
  
  Job Processing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Queues hold on to messages until your job processors process them. They are also cheap and highly scalable. Job processors are code that takes messages from the job queues and processes them. They can scale based on the number of messages in the queue.&lt;/li&gt;
&lt;li&gt;In our case, the job processor should make an API call to the appropriate service to send out the notification through a transactional email service.&lt;/li&gt;
&lt;li&gt;Most email, SMS, or similar delivery services have strict guidelines on the amount and quality of messages you send. You should also carefully review these and put proper systems in place. Here is &lt;a href="https://www.notificationapi.com/blog/how-to-prevent-aws-ses-review-and-suspension" rel="noopener noreferrer"&gt;our guide on how to prevent getting suspended on AWS SES&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;You can configure a max number of job processors to avoid hitting the rate limits of the delivery services.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Why do we need job queues and processors?&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;‍Multiple reasons: A) External delivery services are generally slow. The queue mechanism allows you to process these dead jobs asynchronously from the rest of your code. B) The queue mechanism allows you to control the rate of your jobs, thus avoiding getting throttled. C) These external services could face outages. A job queue mechanism lets you decide what to do in cases of job failure without a single line of code, e.g., retry the job every 30 minutes for a maximum of 3 times.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Improvements
&lt;/h2&gt;

&lt;p&gt;Here are a few things that are possible but we haven't covered. If you need any of these capabilities, read the next section.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The architecture of a scalable in-app notification service - they require their own APIs, tables, etc., so they deserve their own article&lt;/li&gt;
&lt;li&gt;Removing notification contents from the code and instead allowing your product and design team to edit the notifications visually without code change&lt;/li&gt;
&lt;li&gt;Dashboard for your team to enable/disable notifications or specific channels without code changes&lt;/li&gt;
&lt;li&gt;Collecting and displaying open/click report &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  A Quicker Approach
&lt;/h2&gt;

&lt;p&gt;There is so much work that goes into building a scalable notification service. That is precisely why we made &lt;a href="https://www.notificationapi.com" rel="noopener noreferrer"&gt;NotificationAPI&lt;/a&gt;: a plug-and-play notification-as-a-service solution. It takes 5 minutes to set up. It is scalable and has every feature you can imagine for your notifications, such as a dashboard for your team to design and configure notifications visually without developer involvement.&lt;br&gt;
‍&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;At its core, all engineering comes down to making tradeoffs between the perfect and the workable.&lt;br&gt;
-- Katie Hafner&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we learned about the architecture of a scalable notification service. We used tools available in all the major cloud providers so that you can build your notifications based on this. Alternatively, you also learned of a notification-as-a-service product that could save you all the trouble. Software engineering, like any other engineering discipline, comes down to trade-offs. Perhaps the decision tree and table in our &lt;a href="https://www.notificationapi.com/blog/ultimate-guide-on-notification-services" rel="noopener noreferrer"&gt;ultimate guide on notification services&lt;/a&gt; can help you figure out what trade-offs you make.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>systems</category>
      <category>serverless</category>
      <category>microservices</category>
    </item>
  </channel>
</rss>
