Back to Novu

README

packages/stateless/README.md

3.15.03.1 KB
Original Source

📦 Install

bash
npm install @novu/stateless
bash
yarn add @novu/stateless

🔨 Usage

ts
import { NovuStateless, ChannelTypeEnum } from '@novu/stateless';
import { SendgridEmailProvider } from '@novu/providers';

const novu = new NovuStateless();

await novu.registerProvider(
  new SendgridEmailProvider({
    apiKey: process.env.SENDGRID_API_KEY,
    from: '[email protected]',
  }),
);

const passwordResetTemplate = await novu.registerTemplate({
  id: 'password-reset',
  messages: [
    {
      subject: 'Your password reset request',
      channel: ChannelTypeEnum.EMAIL,
      template: `
          Hi {{firstName}}!

          To reset your password click <a href="{{resetLink}}">here.</a>

          {{#if organization}}
            
          {{/if}}
      `,
    },
  ],
});

await novu.trigger('<REPLACE_WITH_EVENT_NAME>', {
  $user_id: '<USER IDENTIFIER>',
  $email: '[email protected]',
  firstName: 'John',
  lastName: 'Doe',
  organization: {
    logo: 'https://evilcorp.com/logo.png',
  },
});

Providers

Novu provides a single API to manage providers across multiple channels with a simple-to-use interface.

💌 Email

📞 SMS

📱 Push

👇 Chat

📱 In-App

Other (Coming Soon...)

  • PagerDuty