DEV Community

Gabriel Baldez
Gabriel Baldez

Posted on

I Built a Unified Notification Library for Java (Email, Slack, Telegram, SMS, and more)

Every backend system eventually needs notifications.

You send emails for confirmations, Slack alerts for deployments, SMS for verification codes, Discord messages for internal tools, and webhooks for integrations.

The problem is that each channel has its own SDK, configuration style, authentication, and API.

Before long, your codebase ends up looking like this:

  • JavaMail for email
  • Twilio SDK for SMS
  • Slack webhook calls
  • Telegram Bot API
  • Custom HTTP clients for other services

Every integration is different.

So I built NotifyHub.

The Idea

NotifyHub is an open-source notification library for Java and Spring Boot that provides one unified API to send notifications across multiple channels.

Instead of integrating every provider separately, you use a single fluent interface.

Example:

notify.to("user@email.com")
      .via(Channel.EMAIL)
      .fallback(Channel.SLACK)
      .subject("Order Confirmed")
      .content("Your order has shipped!")
      .send();
Enter fullscreen mode Exit fullscreen mode

One API. Multiple channels.

Supported Channels

NotifyHub currently supports 20+ channels, including:

  • Email (SMTP)
  • Slack
  • Telegram
  • Discord
  • SMS
  • WhatsApp
  • Microsoft Teams
  • Google Chat
  • Firebase Push
  • Webhooks
  • Twitter / X
  • LinkedIn
  • Notion
  • Twitch
  • YouTube
  • Instagram
  • Facebook

And you can easily add custom channels by implementing a single interface.

Features

NotifyHub is more than just a message sender.

It includes infrastructure features commonly needed in real systems:

Fluent API

Readable builder pattern:

notify.to(user)
      .via(Channel.EMAIL)
      .subject("Security Alert")
      .content("Login from a new device detected")
      .send();
Enter fullscreen mode Exit fullscreen mode

Fallback Chains

If one channel fails, automatically try another.

Example:

WhatsApp → SMS → Email

Retry + Dead Letter Queue

Failed messages retry automatically with configurable backoff.
If all retries fail, the message goes to a DLQ for inspection.

Templates

Email and message templates with Mustache.

Scheduling

Send notifications later using delays or timestamps.

Batch Sending

Send to thousands of recipients with isolation for failures.

Async Support

All sends can run asynchronously using CompletableFuture.

Delivery Tracking

Each notification returns a delivery receipt with status and metadata.

Spring Boot Integration

NotifyHub integrates directly with Spring Boot.

Add the dependency:

<dependency>
    <groupId>io.github.gabrielbbaldez</groupId>
    <artifactId>notify-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>
Enter fullscreen mode Exit fullscreen mode

Configure your channels:

notify:
  channels:
    email:
      host: smtp.gmail.com
      port: 587
      username: ${GMAIL_USER}
      password: ${GMAIL_PASS}
Enter fullscreen mode Exit fullscreen mode

Inject and use it:

@Autowired
NotifyHub notify;
Enter fullscreen mode Exit fullscreen mode

That's it.

REST API Mode

If you don't use Java, you can run NotifyHub as a Docker container and send notifications through HTTP.

Example:

docker run -p 8080:8080 notifyhub-api
Enter fullscreen mode Exit fullscreen mode

Then call it from any language:

POST /send/email
POST /send/discord
POST /send/slack
Enter fullscreen mode Exit fullscreen mode

AI Integration

NotifyHub also includes an MCP server that exposes tools for AI assistants.

This means tools like:

  • Claude
  • Cursor
  • AI coding assistants

can send notifications directly.

Example prompt:

Send an email to john@example.com saying the deploy finished.

The AI calls the NotifyHub tool and sends it.

Why I Built This

In many backend systems, notifications are scattered across services with different libraries and inconsistent patterns.

The goal of NotifyHub is to provide:

  • a clean abstraction
  • a consistent API
  • a modular architecture
  • and a simple developer experience

Project Links

Project page
https://gabrielbbaldez.github.io/notify-hub/

GitHub
https://github.com/gabrielbbaldez/notify-hub

Feedback Welcome

This project is still evolving, and I'd love feedback from other developers.

Especially about:

  • missing channels
  • API design
  • real-world use cases
  • architecture improvements

Top comments (0)