Git Product home page Git Product logo

notificationchannel's Introduction

Multi-Channel Notification Delivery System

This repository contains the code for a multi-channel notification delivery system implemented in Node.js. It supports sending notifications via push notifications, SMS, and email.

Table of Contents

  1. Features
  2. Prerequisites
  3. Installation
  4. Usage
  5. Demo
  6. API Endpoint
  7. Code Structure
  8. Postman Collection
  9. Credits
  10. License

Features

  • Send notifications to multiple channels: Web push , SMS, and email.
  • Easily extensible to support additional notification channels.
  • Built-in validation checks for input data.
  • CORS support for handling cross-origin requests.

Prerequisites

  • Node.js installed on your machine
  • Twilio account for sending SMS
  • SMTP server for sending email - MailTrap
  • Web push server for sending push notifications

Installation

  1. Clone the repository:

    git clone <repository_url>
  2. Install dependencies:

    npm install
  3. Set up environment variables by creating a .env file in the root directory and adding the necessary configuration. Use .env.example as a template

Usage

  1. Setup Twilio Account to send SMS

  2. Setup MailTrap Account to recieve emails

  3. Update .env file

    TWILIO_ACCOUNT_SID , TWILIO_AUTH_TOKEN , TWILIO_PHONE_NUMBER ,EMAIL_USER , EMAIL_PASSWORD , EMAIL_HOST , EMAIL_PORT
  4. Start the server:

    npm start
  5. Run index.html file and click on Enable Notifications (acting as client)

Button

  1. You will see a Service Worker running in Developer Tools -> Application -> ServiceWorker

Button

[ You will find the endpoint , authKey , p256dhKey (subscription details ) logged to the running service ]

  1. Use the provided Postman collection to test the API endpoints for sending notifications.

DEMO

Email

Email

Web-Push Notification

web-push notification

SMS

web-push notification

API Endpoint

Send Notification

  • URL: /notify
  • Method: POST
  • Body: JSON object with the following fields:
    • message: The content of the notification.
    • channels: An array of channels to send the notification to (push, sms, email).
    • targetUsers: An array of objects containing details of the target users/devices for each channel.

Code Structure

  • app.js Main application file handling API requests and routing.
  • pushNotificationService.js: Service for sending push notifications ( currently sending to the all subscribed clients , but configurable )
  • smsService.js: Service for sending SMS messages.
  • emailService.js: Service for sending emails.
  • validation.js: Module for input validation.

Postman Collection

You can import the provided Postman collection to test the API endpoints locally.

Download Postman Collection

Credits

  • This project uses various libraries and services, including Twilio for SMS, Nodemailer for email, and web-push for push notifications.

License

This project is licensed under the MIT License.

notificationchannel's People

Contributors

aakash-rana avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.