Java Quickstart
Learn how to integrate Novu into your Java project on the fly and send notifications across different channels (SMS, Email, Chat, Push). In this Quickstart, you will learn how to:- Install and Set up the Novu Java SDK.
- Configure a Notification Channel Provider.
- Set up a Notification Workflow.
- Create a Subscriber and update a Subscriber’s information.
- Send your first Notification to a Subscriber.
- Send Notifications via Topics.
Requirements
To be able to use this Quickstart, you would need to have the following:- A Novu account, if you don’t have one yet, sign up for free.
- A working Java development environment with JDK 17 and Springboot Framework of 3.1.2+.
Install and Set up the Novu Java SDK in your project
First, you need to import the library into your application. If you use Maven, add the dependency to thepom.xml
file;
build.gradle
file;
Novu.java
class using any of the following constructors:
Set up a Channel Provider
A channel provider is a service that provides one or more notification functionality such as sending an email, SMS, push notification, etc. Our integration store includes four channels: Email, SMS, Chat, and Push. These channels have multiple providers associated with them.Channel | Providers |
---|---|
MailGun, Mandrill, MailJet, Amazon SES, Sendgrid, Postmark, Netcore | |
SMS | Twilio, Amazon SNS, Plivo, SMS, SMSCentral, Kannel, Infobip, Termii |
Chat | Mattermost, Slack, Microsoft Teams, Discord |
Push | FCM, APNS, Expo |
Create a Notification Workflow
A notification workflow is the blueprint for the notifications that will be sent. It holds the entire flow of messages sent to the subscriber. This is where all the different channels are tied together under a single entity. The workflow includes the following:- Notification workflow name and Identifier.
- Channel tailored content:
Channel | Content Style | Custom Variables{{handlebars}} format |
---|---|---|
HTML | ✅ | |
Visual Editor | ✅ | |
SMS | Text | ✅ |
Chat | Text | ✅ |
In-App | Text | ✅ |
Push | Text | ✅ |
Proper authorization needs to be set for the Chat channel for subscribers.
- Click Workflows on the left sidebar of your Novu dashboard.
- Click the Create Workflow button on the top right.

Creating a workflow in Novu dashboard
- The name of a new notification workflow is currently Untitled, rename it to a more suitable title.

Renaming the newly created notification workflow
- Select Email as the channel you want to add, by dragging it from the right sidebar.

Adding email channel to the notification workflow we created above
-
Click on the Email in the workflow and edit it as per this image. Don’t forget to add the fields in the editor which is supposed to be updated with dynamic values that will be sent when calling the API.
Adding email and description to the editor in the notification workflow we created above
-
Also, add the variables in the Variables section in the test tab and try testing it by sending the email to your email address using the Send Test Email button at the bottom right.
Adding variables to the 'variables' section
Create and Update a Subscriber’s Information
The recipients of a triggered notification are called subscribers. Click Subscribers on the left sidebar of the Novu dashboard to see all subscribers. By default, the dashboard will display a subscriber, as you were added automatically during sign-up.
Navigate to `Subscribers` from the left sidebar
phone
, avatar
, and data
. The data
field can accept an Object or a Map with the info you want to attach to the subscriber.
To create all of your subscribers, you need to programmatically add them to Novu.
Trigger a Notification
Copy and paste the following code into your app to trigger a notification to a Subscriber:- The value of
payload
is an array of the data that you want to be dynamically injected into the notification workflow content. - The value of
subscriberId
is the ID of the subscriber on Novu. Replace12345
with your subscriber ID.
Topics
Novu provides a simple API that offers an easy interface for triggering notifications to multiple subscribers at once. This API is called Topics and allows users to manage their bulk notifications without having to implement complex loops. A topic is identified by a custom key that is provided by the user, and this key will be the identifier used in the Topics API.The topic key should be unique and can’t be changed once chosen. Novu also caters for key uniqueness behind the scenes.
Create a Topic
Copy and paste the following code into your app to create a topic:- When creating a
key
, ensure it is unique and accurately identifies the topic. Document naming conventions and communicate them to team members to avoid confusion and ensure a smooth workflow. - The value of
name
should be a descriptive topic name.
Add Subscribers to a Topic
Copy and paste the following code into your app to add subscribers a topic:Send a Notification to a Topic
Thanks to the topics feature, it is possible to trigger a notification to all subscribers assigned to a topic. This helps avoid listing all subscriber identifiers in theto
field of the notification trigger.
To trigger a notification to all subscribers of a topic, copy and paste the code below:
Next Steps
Great job! :clap: If you’ve reached this point, you should have successfully created a subscriber, notification workflow, configured a channel provider, triggered a single notification, created a topic, added a subscriber to a topic in your application. To learn more about notifications and explore Novu’s features and capabilities, check out:- Novu Java SDK - Dive deeper into the SDK and explore a lot of features.
- Novu Digest Engine - Learn how to aggregate multiple trigger events into a single message and deliver it to the subscriber.
- Novu Notification Center - Learn how to integrate a rich, ready-to-use real-time UI notification center into your app.