GithubHelp home page GithubHelp logo

kaushalvivek / notification-microservice Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 2.0 46 KB

A highly scalable microservice to handle WhatsApp, SMS and email-based notifications.

License: MIT License

Dockerfile 3.19% JavaScript 91.81% Shell 5.00%
microservice docker node aws sqs twilio sendgrid-api

notification-microservice's Introduction

Notification Microservice

https://img.shields.io/badge/version-v1.0.0-green

Introduction

This project is a highly scalable micro-service to handle all the notifications (Email/SMS/WhatsApp) that you would require to schedule for contact from your small-business. It uses Amazon's SQS queuing service, SendGrid's email API and Twilio WhatsApp and SMS API to schedule notifications. Support would be added for other service-providers as the project evolves.

Features

  • Simple/Bulk WhatsApp notification through a single API call.
  • Simple/Bulk SMS notification through a single API call.
  • Simple/Bulk rich text Email through a single API call.
  • Rate limiter for streamlining bulk notification requests.

QuickStart

git clone https://github.com/kaushalvivek/notification-microservice.git
cd notification-microservice
  • Create environment file
vim .env

Provide all the values as specified in sample_env.sh

  • Start the micro-service
sudo docker-compose up -d

Usage

Sending Emails

POST request to : host:PORT/api/v1/notify/email
Request body:

{
    "data":[
        {
            "content":{
                "subject" : "Sample Email's Subject",
                "html" : "<p> Sample email's body</p>"
            },
            "targets":[
                "[email protected]",
                "[email protected]"
            ]
        }
         {
            "content":{
                "subject" : "Sample Email 2's Subject",
                "html" : "<p> Sample email 2's body</p>"
            },
            "targets":[
                "[email protected]"
            ]
        }
    ]
}

Sending WhatsApp messages

POST request to : host:PORT/api/v1/notify/whatsapp
Request body:

{
    "data":[
        {
            "content":{
                "body" : "This is a sample message!"
            },
            "targets":[
                {
                    "countryCode":"+1",
                    "phone":"123456789"
                },
                {
                    "countryCode":"+91",
                    "phone":"9876543211"
                }
            ]
        }
        {
            "content":{
                "body" : "This is another sample message!"
            },
            "targets":[
                {
                    "countryCode":"+1",
                    "phone":"123456789"
                }
            ]
        }
    ]
}

Sending SMS

POST request to : host:PORT/api/v1/notify/sms
Request body:

{
    "data":[
        {
            "content":{
                "body" : "This is a sample message!"
            },
            "targets":[
                {
                    "countryCode":"+1",
                    "phone":"123456789"
                },
                {
                    "countryCode":"+91",
                    "phone":"9876543211"
                }
            ]
        }
        {
            "content":{
                "body" : "This is another sample message!"
            },
            "targets":[
                {
                    "countryCode":"+1",
                    "phone":"123456789"
                }
            ]
        }
    ]
}

Contributing

Feel free to create issues in this repository for contribution. Contributions guidelines would evolve along with the project. Tests for integration would be added soon.

License

MIT License

Copyright (c) 2021 Vivek Kaushal

notification-microservice's People

Contributors

kaushalvivek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

notification-microservice's Issues

Add tests

Add unit and integration tests for both API and Consumer. Additionally, setup GitHub tests upon merge to main.

Splitted messages before pushing into AWS-SQS

@kaushalvivek Why before pushing the messages into SQS, it's splitted into groups of 10?

exports.queueMessages = async function (messages, queueUrl) {
  try {
    const splittedArray = splitArray(messages, 10) **/// WHY ??**
    for (const arr of splittedArray) {
      const params = {
        QueueUrl: queueUrl,
        Entries: []
      }
      arr.forEach(message => {
        params.Entries.push({
          Id: uuid.v4(),
          MessageBody: JSON.stringify(message)
        })
      })
      await sqs.sendMessageBatch(params).promise()
    };
    return (201)
  } catch (e) {
    throw new Error(e.message)
  }

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.