Set up your local environment
Start the Local Studio by running:Install packages
Install the Novu Framework package:Add the NovuModule to your application
The
NovuModule is a NestJS module that registers the Novu Endpoint in your application.The following example does not support NestJS dependency injection. If you need to @Injectable dependencies in your workflow definition, see Advanced Usage.src/app.module.ts
Create your workflow definition
Add anovu folder in your src folder as such src/novu/workflows.ts that will contain your workflow definitions.app/novu/workflows.ts
Start your application
Start your NestJS application with the Novu Endpoint configured.If your NestJS application is running on other than4000 port, restart the npx novu dev command with the port:Test your endpoint
Test your workflow by triggering it from the Local Studio or using the Novu API:Deploy your application
Deploy your application to your preferred hosting provider. Make sure the/api/novu endpoint is accessible from the internet.For local development and testing, you can use tools like ngrok to expose your local server to the internet.- Learn about Workflow Controls to expose no-code editing capabilities
- Explore different Channel Steps like Email, SMS, Push, and more
- Set up Action Steps like Delay and Digest
- Check out our React Email integration for building beautiful email templates
Advanced Usage (Dependency Injection)
If you need to inject dependencies into your workflow definition, you can use theregisterAsync method.
Add the NovuModule using the registerAsync method to your AppModule.
src/app.module.ts
UserService is available below with hardcoded values, but in a real-world application you might use a database or an external API to fetch the user’s name.
src/user.service.ts
NotificationService to use the injected UserService.
src/notification.service.ts