Skip to main content

Organization Invite

In a collaborative project, you may want to invite others to join the organization.

import { Notifire, ChannelTypeEnum } from "@notifire/core";import { SendgridEmailProvider } from "@notifire/sendgrid";
const notifire = new Notifire();
await notifire.registerProvider(  new SendgridEmailProvider({    apiKey: process.env.SENDGRID_API_KEY,  }));
// Defined in a file or folder responsible for managing templatesconst inviteToOrganizationTemplate = await notifire.registerTemplate({  id: "invite-to-organization",  messages: [    {      subject: "You've been invited to join {{organizationName}}",      channel: ChannelTypeEnum.EMAIL,      template: `          Hi {{firstName}}!                    You've been invited by <b>{{inviterName}}</b> to join  <b>{{organizationName}}</b>.                    Click <a href="{{inviteLink}}">here</a> to join      `,    },  ],});
// Triggered in the relevant part of the business logic of your codeawait notifire.trigger("invite-to-organization", {  $user_id: "<USER IDENTIFIER>",  $email: "<USER EMAIL>",  firstName: "John",  lastName: "Doe",  inviterName: "Jannie Doe",  inviteLink: "",  organizationName: "My Org",});