npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tsc_tech/medusa-plugin-notification-template

v0.0.24

Published

A starter for Medusa plugins.

Readme

📧 Medusa Notification Template Plugin

A Medusa plugin that provides notification template management functionality for your Medusa e-commerce store. This plugin allows you to create, edit, and manage notification templates for various events in your system.

✨ Features

  • Create and manage notification templates
  • Support for dynamic event-based templates
  • Template variables support using Handlebars syntax
  • Admin UI integration for template management
  • Email notification support with customizable subject, to, cc, and bcc fields

📋 Unavailable Events

The following events are not available in the current version of the plugin:

  • auth.password_reset
  • shipment.created
  • delivery.created
  • invite.accepted
  • invite.created
  • invite.deleted
  • invite.resent

📦 Installation

npm install @tsc_tech/medusa-plugin-notification-template

# or using yarn
yarn add @tsc_tech/medusa-plugin-notification-template

# Run migration
npx medusa db:migrate

📋 Requirements

  • Medusa server > 2.5.0
  • Node.js >= 20

⚙️ Configuration

Add the plugin to your medusa-config.js:

const plugins = [
  // ... other plugins
  {
    resolve: "@tsc_tech/medusa-plugin-notification-template",
    options: {
      // plugin options if any
    }
  }
]

🚀 Usage

🖥️ Admin UI Walkthrough

The plugin interface will be displayed under the "Extensions" section. The "Notification Template" feature includes the following routes:

  1. Template List View (/notification-template)

    • View all notification templates
    • Create new templates
    • Edit existing templates
    • Delete templates
  2. Create Template View (/notification-template/create)

    • Create new notification templates with:
      • Event name
      • Template content
      • Subject
      • To, CC, and BCC fields
  3. Edit Template View (/notification-template/edit)

    • Modify existing templates
    • Preview template with sample data

🔄 Using in Workflows

To use the notification template in your workflow hook, import the subscriberWorkflow functions from the @tsc_tech/medusa-plugin-notification-template/workflows/subscriber-workflow:

import { subscriberWorkflow } from "@tsc_tech/medusa-plugin-notification-template/workflows/subscriber-workflow";
subscriberWorkflow.hooks.subscriberHook(({ name, data }, { container }) => {
  const notificationService =
    container.resolve("notification-template");
  const value = {
    otp: "1234",
  };
  notificationService.setExtraData(value, container);
});

🎯 Purpose of the Subscriber Hook

The subscriberHook in the subscriberWorkflow allows plugins to add extra data to notification templates. This extra data can be customized to suit the plugin's needs, enabling dynamic and flexible display of information in the templates. By using the setExtraData function, you can pass additional data to the workflow, which can then be utilized in the templates to create personalized and relevant notifications.

📝 Template Variables

Templates support Handlebars syntax for dynamic content. Available variables depend on the event type. For example:

Hello {{customer.first_name}},

Your order #{{order.display_id}} has been confirmed.

Thank you for shopping with us!

📧 Notification Service Implementation

Send Method Example

Here's an example of the notification service's send method:

async send(
    notification: ProviderSendNotificationDTO
  ): Promise<ProviderSendNotificationResultsDTO> {
    console.log({ notification });

   // your service code as it is
  }

Notification Object Structure

The notification object passed to the send method has the following structure:

{
  id,                // Notification ID
  channel,          // Communication channel (e.g., 'email')
  to,               // Primary recipient
  data: {
    // Contains all email-specific data and template information
    id,
    template,       // Raw template with handlebars syntax
    subject,        // Email subject
    event_name,     // Type of event (e.g., 'product.updated')
    to: [],              // Array of recipients
    cc: [],              // Array of CC recipients
    bcc: [],             // Array of BCC recipients
    created_at,
    updated_at,
    deleted_at,
    emailBody      // Processed template content
  },
  template,         // Processed template content
  content: {
    // Contains dynamic data used in template rendering
    entityDetails: {}    // Object containing entity-specific data
  },
  provider_id      // ID of the notification provider (e.g., 'smtp')
}

Important Structure Notes:

  1. The data object contains all email-related configurations including:

    • Template configuration (template, subject)
    • Recipient information (to, cc, bcc)
    • Event information (event_name)
    • Email content (emailBody)
  2. The content object contains:

    • entityDetails: Dynamic data that will be used to populate the template variables. For example, if it's a product update notification, this would contain the product details.

This structure allows for separation between email configuration (data) and the dynamic content (content.entityDetails) that will be used in the template.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📜 License

MIT License