How to Get Started with Novu: The Essentials of Notification Management

Nov 20, 2023 | Programming

In the ever-evolving world of software development, efficient communication through notifications is crucial. Enter Novu, an open-source notifications framework that simplifies the integration of notifications into applications. With Novu, product teams can effortlessly manage notification content and messaging.

Why Choose Novu?

Novu stands out by offering a unified API for sending notifications across various channels. Picture it like a Swiss Army knife for notifications – powerful, adaptable, and ready at a moment’s notice. Whether it’s sending an email, a text message, or a push notification, Novu has you covered.

Features That Empower Your Notifications

  • One API for all messaging channels (Inbox, Email, SMS, Push, Chat).
  • GitOps flow fully managed and deployed from your CI.
  • Custom workflows with flexible content messages.
  • Advanced layouts and design management through a CMS.
  • Real-time notifications and subscriber controls for preferences.

How to Get Started with Novu

Getting started with Novu can be as easy as ABC. Here are two simple paths to embark on your Novu journey:

  1. Open your terminal and type the following command:
    npx novu@latest dev
  2. Alternatively, consider creating a free cloud account.

Walking Through the Code: Notifications as Workflows

To further illustrate how you can leverage Novu’s capabilities, imagine you’re a conductor orchestrating a symphony. In this analogy, each instrument (or workflow step) needs to play at the right time for the music (notifications) to flow harmoniously. Here’s a snippet that demonstrates this concept:

import workflow, CronExpression from @novu/framework;
import z from 'zod';
import render from '@react-email/render';

const commentWorkflow = workflow('comment-workflow', async (event) => {
    const digest = await event.step.digest('digest-comments', (controls) => ({ 
        cron: controls.schedule  
    }));

    await event.step.email('digest-email', async (controls) => ({
        subject: controls.subject,
        body: render(WeeklyDigestEmail, { ...controls, events: digest.events }),
    }), {
        skip: () => !digest.events.length,
        controlSchema: z.object({ 
            subject: z.string().default('Hi subscriber.firstName - Acme Comments'), 
            openAiModel: z.enum(['gpt-3.5-turbo', 'gpt-4o']).default('gpt-4o'), 
            aiPrompt: z.string().default('Produce a concise comment digest') 
        })
    });

    await commentWorkflow.trigger({
        payload: { name: 'John', comment: 'Are you free to give me a call?' },
        to: 'jane@acme.com'
    });
});

In the code above, the workflow is akin to a conductor leading different sections of an orchestra to ensure the final composition is both seamless and meaningful. At each ‘event.step’, we determine when and how to send notifications, ensuring that the right message reaches the right audience at the right moment.

Creating an Embeddable Inbox Component

Novu allows you to easily set up an embeddable notification center in your web app. Just like adding a spice rack to your kitchen, it enhances functionality without disrupting the workflow. You can use the React component or build your own via the API and SDK.

Troubleshooting Common Issues

If you encounter any problems while working with Novu, don’t fret. Here are some tips that might help:

  • Check your API keys for proper configuration.
  • Ensure your environment supports the frameworks you are using.
  • If you face persistent issues, don’t hesitate to reach out on our Discord server.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Final Thoughts

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox