Sign inSign up

woobase/product-base.notification

By woobase

•Updated about 5 years ago

It's a uncomplicated API sends messages by MS Teams and E-mail with settings previously storage.

Image
0

10K+

woobase/product-base.notification repository overview

⁠Notification Service

It's a uncomplicated API sends messages by Microsoft Teams and E-mail with settings previously storage by itself, to abstract their complexities.

Takes advantage of Apprise API⁠ through your network with a user-friendly self-guided API.

For now it's available to send notifications to 2 services (Email and teams).
A production ready micro-service at your disposal.

image

⁠Quick try

⁠docker-compose up me!

About docker-compose, see it here⁠.

version: "3.1"

services:
  mongo:
    image: mongo:4.4.1
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example

  apprise:
    image: caronc/apprise
    restart: always

  notification-service:
    image: woobase/product-base.notification:latest
    restart: always
    environment:
      HttpAppriseBaseUrl: "http://apprise:8000"
      MongoConnection__ConnectionString: "mongodb://root:example@mongo:27017"
      MongoConnection__Database: "MyDatabase"
    ports:
      - 8080:80
docker-compose -f docker-compose.yml up -d
⁠docker-compose with RabbitMQ!

You may also want to send your notifications relying message queues security like RabbitMQ⁠.

version: "3.1"

services:
  mongo:
    image: mongo:4.4.1
    container_name: mongo
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: password
    ports:
      - 27017:27017

  apprise:
    image: caronc/apprise:latest
    container_name: apprise
    restart: always
    ports:
      - 8000:8000
    volumes:
      - /var/lib/apprise/config:/config
  
  rabbitmq:
    image: masstransit/rabbitmq:latest
    container_name: rabbitmq
    restart: always
    environment:
      RABBITMQ_DEFAULT_USER: user
      RABBITMQ_DEFAULT_PASS: password
    ports:
      - 15672:15672
      - 5672:5672

  notification-consumer:
    image: woobase/product-base.notification-consumer:latest
    container_name: notification-consumer
    restart: always
    environment:
      HttpAppriseBaseUrl: "http://apprise:8000"
      MongoConnection__ConnectionString: "mongodb://root:password@mongo:27017"
      MongoConnection__Database: "DataBaseName"
      RabbitMqSettings__Host: rabbitmq
      RabbitMqSettings__Username: user
      RabbitMqSettings__Password: password

  notification-service:
    image: woobase/product-base.notification:latest
    container_name: notification-service
    restart: always
    environment:
      HttpAppriseBaseUrl: "http://apprise:8000"
      MongoConnection__ConnectionString: "mongodb://root:password@mongo:27017"
      MongoConnection__Database: "DataBaseName"
      RabbitMqSettings__Host: rabbitmq
      RabbitMqSettings__Username: user
      RabbitMqSettings__Password: password
      Jwt__Enabled: "false"
    ports:
      - 8080:80

⁠Create a connector configuration

Here you should store the connectors' settings to use after when you'll send notifications using only the name of configuration key.

If some parameter is wrong, them Notification Service will guide you to fit the requirements.

With Email:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"keyname":"business","providerType":"email", "Parameters":{"userid": "username", "pass": "password", "domain": "gmail.com", "to": "email1,email2"}}' \
  http://localhost:8080/api/v1/connector

With Teams you need to generate an incoming webhook⁠:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"keyname":"buildStatuses","providerType":"teams", "Parameters":{"webhookUrl": "your webhook from"}}' \
  http://localhost:8080/api/v1/connector
⁠Parameters list to create a connector for Microsoft Teams:
NameRequiredDescription
keynameyesIt's name of channel configuration. It'll be using to send notification.
providerTypeyesIt represents the name of type connector, in this case its value should be "teams".
webhookUrlyesIt's a web hook url belongs a channel group of Microsoft Teams is going to receive the notification. See how to get, here⁠.
⁠Parameters list to create a connector for E-mail:
NameRequiredDescription
keynameyesIt's name of channel configuration. It'll be using to send notification.
providerTypeyesIt represents the name of type connector, in this case its value should be "teams".
domainyesIt's a domain name. If your email is [email protected]⁠, your domain is example.com.
useridnoIt's a name of email user. If your email is [email protected]⁠, your userid is username.
passnoIt represents the password of email who sends notifications.
smtpnoIt's a SMTP Server address.
portnoIt's the SMTP por, by default is 25.
modenoThe Mode allows you to change the connection method. Some sites only support SSL (mode=ssl) while others only support STARTTLS (mode=starttls). The default value is starttls.
fromnoIf you want the email address ReplyTo address to be something other then your own email address, then you can specify it here. This field can override on sending.
namenoWith respect to {from_email}, this allows you to provide a name with your ReplyTo address.
tonoIt's represents who receive the notification. This field can override on sending.
ccnoCarbon Copy email address(es). More than one can be separated with a space and/or comma.
bccnoBlind Carbon Copy email address(es). More than one can be separated with a space and/or comma.

For more details of email parameters, see it here⁠.

⁠Send notification using previous setup

Now to send notification you just need to provide a list of channel (created in before step), title and body!

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"channels":["business", "buildStatuses"],"title":"Hello world", "body": "Thank you!"}' \
  http://localhost:8080/api/v1/notification

When sending notification to email, you can overwrite the recipient list using "to" parameter.

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"channels":["business", "buildStatuses"],"title":"Hello world", "body": "Thank you!", "to": "newEmail1,newEmail2", "from": "myEmail"}' \
  http://localhost:8080/api/v1/notification
⁠Parameters list to send notification:
NameRequiredDescription
channelsyesA list of settings key, created on configurations.
titleyesThe title of notification, can be a phrase or a name.
bodyyesIt's the content of notification.
tonoThis field override who receives the message. It only works to send e-mail.
fromnoThis field override the name who sends the message. It only works to send e-mail

⁠License

MIT License

Copyright 2021 Woobase

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tag summary

Content type

Image

Digest

Size

86.7 MB

Last updated

about 5 years ago

docker pull woobase/product-base.notification