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 🙏

© 2026 – Pkg Stats / Ryan Hefner

multi-notifications-channel

v1.0.0

Published

Universal multi-channel notification system for Node.js with Email, SMS, and Slack support - works with any framework

Downloads

103

Readme

multi-notifications-channel

Universal multi-channel notification system for Node.js with Email, SMS, and Slack support. Works with any JavaScript/TypeScript framework or environment.

npm version License: MIT

✨ Features

  • 📧 Email - Brevo provider with HTML & template support
  • 📱 SMS - Twilio provider with OTP verification
  • 💬 Slack - Full integration (DMs, channels, Block Kit)
  • 🔄 Multi-Channel - Send to multiple channels with one call
  • 🌍 Universal - Works with Express, Next.js, Nuxt.js, plain Node.js, and more
  • 🎯 Type-Safe - Full TypeScript support
  • Zero Dependencies - No framework lock-in
  • 🔌 Extensible - Easy to add custom providers

📦 Installation

npm install multi-notifications-channel

Provider SDKs

Install only the providers you need:

# For email support
npm install @getbrevo/brevo

# For SMS support
npm install twilio

# For Slack support
npm install @slack/web-api

🚀 Quick Start

import { NotificationService } from 'multi-notifications-channel';

const notifier = new NotificationService({
  brevo: {
    apiKey: process.env.BREVO_API_KEY!,
    senderEmail: '[email protected]',
  },
  twilio: {
    accountSid: process.env.TWILIO_ACCOUNT_SID!,
    authToken: process.env.TWILIO_AUTH_TOKEN!,
    phoneNumber: process.env.TWILIO_PHONE_NUMBER!,
  },
  slack: {
    botToken: process.env.SLACK_BOT_TOKEN!,
  },
});

// Send email
await notifier.sendEmail({
  to: '[email protected]',
  subject: 'Welcome!',
  content: '<h1>Hello!</h1>',
});

// Send SMS
await notifier.sendSMS({
  phoneNumber: '+1234567890',
  message: 'Your code is 123456',
});

// Send Slack DM
await notifier.sendSlackDMByEmail('[email protected]', 'Hello from Slack!');

📚 Framework Examples

Express.js

import express from 'express';
import { NotificationService } from 'multi-notifications-channel';

const notifier = new NotificationService({ /* config */ });
const app = express();

app.post('/api/notify', async (req, res) => {
  const result = await notifier.sendEmail({
    to: req.body.email,
    subject: 'Notification',
    content: req.body.message,
  });
  res.json(result);
});

Next.js (App Router)

// app/api/notify/route.ts
import { NotificationService } from 'multi-notifications-channel';

const notifier = new NotificationService({ /* config */ });

export async function POST(request: Request) {
  const { to, subject, content } = await request.json();
  
  const result = await notifier.sendEmail({ to, subject, content });
  
  return Response.json(result);
}

Nuxt.js (Server API)

// server/api/notify.post.ts
import { NotificationService } from 'multi-notifications-channel';

const notifier = new NotificationService({ /* config */ });

export default defineEventHandler(async (event) => {
  const { to, subject, content } = await readBody(event);
  
  return await notifier.sendEmail({ to, subject, content });
});

Plain Node.js

import { NotificationService } from 'multi-notifications-channel';

const notifier = new NotificationService({ /* config */ });

await notifier.sendEmail({
  to: '[email protected]',
  subject: 'Hello',
  content: 'World!',
});

📖 Usage Guide

Email Notifications

Send HTML Email

await notifier.sendEmail({
  to: '[email protected]',
  subject: 'Order Confirmation',
  content: '<h1>Thank you!</h1><p>Order #12345</p>',
});

Send Template Email

await notifier.sendEmailWithTemplate({
  to: '[email protected]',
  subject: 'Monthly Report',
  templateId: 1,
  params: {
    name: 'John',
    month: 'January',
  },
});

SMS Notifications

Send SMS

await notifier.sendSMS({
  phoneNumber: '+1234567890',
  message: 'Your order has shipped!',
});

Send & Verify OTP

// Send OTP
await notifier.sendVerificationCode('+1234567890');

// Verify OTP
const isValid = await notifier.verifyCode('+1234567890', '123456');

Slack Notifications

Send DM by User ID

await notifier.sendSlackDM('U1234567890', 'Hello!');

Send DM by Email

await notifier.sendSlackDMByEmail('[email protected]', 'Hello!');

Send to Channel

await notifier.sendSlackChannel('C1234567890', 'Deployment complete!');

Send with Block Kit

await notifier.sendSlackMessage({
  userId: 'U1234567890',
  message: 'Fallback text',
  blocks: [
    {
      type: 'section',
      text: {
        type: 'mrkdwn',
        text: '*Alert* :warning:\nAction required!',
      },
    },
  ],
});

Multi-Channel Notifications

const result = await notifier.send({
  channels: ['EMAIL', 'SMS', 'SLACK'],
  recipient: {
    email: '[email protected]',
    phone: '+1234567890',
    slackUserId: 'U1234567890',
  },
  subject: 'Critical Alert',
  content: 'Immediate action required!',
});

console.log(`Success: ${result.successCount}/${result.results.length}`);

⚙️ Configuration

Full Configuration

const notifier = new NotificationService({
  // Email provider
  brevo: {
    apiKey: 'your-api-key',
    senderEmail: '[email protected]',
    senderName: 'My App', // optional
  },
  
  // SMS provider
  twilio: {
    accountSid: 'your-account-sid',
    authToken: 'your-auth-token',
    phoneNumber: '+1234567890',
    verifyServiceSid: 'your-verify-sid', // optional, for OTP
  },
  
  // Slack provider
  slack: {
    botToken: 'xoxb-your-bot-token',
  },
  
  // Custom logger (optional)
  logger: customLogger,
  
  // Environment (optional)
  env: 'production',
});

Custom Logger

import { ILogger } from 'multi-notifications-channel';

const customLogger: ILogger = {
  log: (msg, ...args) => console.log(msg, ...args),
  error: (msg, ...args) => console.error(msg, ...args),
  warn: (msg, ...args) => console.warn(msg, ...args),
};

const notifier = new NotificationService({
  logger: customLogger,
  // ... other config
});

🔧 API Reference

NotificationService

Email Methods

  • sendEmail(options) - Send HTML or plain email
  • sendEmailWithTemplate(options) - Send template-based email

SMS Methods

  • sendSMS(options) - Send SMS message
  • sendVerificationCode(phoneNumber) - Send OTP code
  • verifyCode(phoneNumber, code) - Verify OTP code

Slack Methods

  • sendSlackMessage(options) - Flexible Slack messaging
  • sendSlackDM(userId, message, blocks?) - DM by user ID
  • sendSlackDMByEmail(email, message, blocks?) - DM by email
  • sendSlackChannel(channelId, message, blocks?) - Channel message

Multi-Channel

  • send(options) - Send to multiple channels

Utility Methods

  • hasChannel(channel) - Check if channel is available
  • getAvailableChannels() - Get all configured channels
  • getRegistry() - Access provider registry

🔐 Environment Variables

# Brevo
BREVO_API_KEY=your-api-key

# Twilio
TWILIO_ACCOUNT_SID=your-account-sid
TWILIO_AUTH_TOKEN=your-auth-token
TWILIO_PHONE_NUMBER=+1234567890
TWILIO_VERIFY_SERVICE_SID=your-verify-sid

# Slack
SLACK_BOT_TOKEN=xoxb-your-bot-token

🎯 TypeScript Support

Full TypeScript support with comprehensive type definitions:

import {
  NotificationService,
  NotificationChannel,
  NotificationResult,
  SendEmailOptions,
  SendSmsOptions,
  SendSlackOptions,
  MultiChannelOptions,
  ILogger,
} from 'multi-notifications-channel';

📝 Examples

See the examples/ directory for complete examples:

🔄 Migration from NestJS Version

If you're migrating from nestjs-multi-notifications:

Before (NestJS):

@Module({
  imports: [NotificationsModule.forRoot()],
})
export class AppModule {}

// In service
constructor(private notificationsService: NotificationsService) {}

After (Framework-agnostic):

const notifier = new NotificationService({
  brevo: { apiKey: '...', senderEmail: '...' },
});

await notifier.sendEmail({ ... });

📄 License

MIT

🤝 Contributing

Contributions welcome! Please open an issue or PR.

💬 Support

For issues and questions, use GitHub Issues.