All Projects → acutario → Ravenx

acutario / Ravenx

Licence: mit
Notification dispatch library for Elixir applications

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Ravenx

Notify
A dead simple Go library for sending notifications to various messaging services.
Stars: ✭ 727 (+627%)
Mutual labels:  slack, email, notifications
Alertmanager
Prometheus Alertmanager
Stars: ✭ 4,574 (+4474%)
Mutual labels:  slack, email, notifications
Workbase Server
Slack alternative, email integrated, build with Meteor
Stars: ✭ 284 (+184%)
Mutual labels:  slack, email
Chronos
📊 📊 📊 Monitors the health and web traffic of servers, microservices, and containers with real-time data monitoring and receive automated notifications over Slack or email.
Stars: ✭ 347 (+247%)
Mutual labels:  slack, notifications
Laravel Failed Job Monitor
Get notified when a queued job fails
Stars: ✭ 582 (+482%)
Mutual labels:  slack, notifications
Gocd Slack Build Notifier
GoCD (gocd.org) plugin to push build notifications to Slack
Stars: ✭ 96 (-4%)
Mutual labels:  slack, notifications
website-change-monitor
Monitor a website and get email and Slack notifications when specific changes are detected
Stars: ✭ 104 (+4%)
Mutual labels:  slack, email
Glass Isc Dhcp
Glass - ISC DHCP Server Interface
Stars: ✭ 486 (+386%)
Mutual labels:  slack, email
Psslack
PowerShell module for simple Slack integration
Stars: ✭ 231 (+131%)
Mutual labels:  slack, notifications
Yii2 Slack Log
Pretty Slack log target for Yii 2
Stars: ✭ 24 (-76%)
Mutual labels:  slack, notifications
Notifo
Multi channel notification service for collaboration tools, e-commerce, news service and more.
Stars: ✭ 32 (-68%)
Mutual labels:  email, notifications
gnome-email-notifications
Gnome Email Notifications
Stars: ✭ 65 (-35%)
Mutual labels:  notifications, email
slack-texts
SMS notifications for Slack groups
Stars: ✭ 19 (-81%)
Mutual labels:  notifications, slack
Papercups
Open-source live customer chat
Stars: ✭ 4,554 (+4454%)
Mutual labels:  slack, email
content-reminder
⏰ A GitHub Action that reminds you to share your own content
Stars: ✭ 28 (-72%)
Mutual labels:  notifications, email
Craft Brief
Quick, easy, and customizable user-group notifications for Craft CMS.
Stars: ✭ 47 (-53%)
Mutual labels:  slack, notifications
Uptime Monitor App
A PHP application to monitor uptime and ssl certificates
Stars: ✭ 205 (+105%)
Mutual labels:  slack, notifications
Laravel Slack Slash Command
Make a Laravel app respond to a slash command from Slack
Stars: ✭ 215 (+115%)
Mutual labels:  slack, notifications
Diun
Receive notifications when an image is updated on a Docker registry
Stars: ✭ 704 (+604%)
Mutual labels:  slack, notifications
Synology Notifications
Synology notifications service
Stars: ✭ 47 (-53%)
Mutual labels:  slack, notifications

Ravenx

Current Version Build Status

Notification dispatch library for Elixir applications (WIP).

Installation

  1. The package can be installed as simply as adding ravenx to your list of dependencies in mix.exs:
  def deps do
    [{:ravenx, "~> 1.1.3"}]
  end
  1. Add Ravenx to your list of applications in mix.exs. This step is only needed if you are using a version older than Elixir 1.4.0 or you already have some applications listed under the applications key. In any other case applications are automatically inferred from dependencies (explained in the Application inference section):
def application do
  [
    applications: [
      ...,
      :ravenx
    ]
  ]
end

Strategies

From version 2.0, strategies come in separate packages, so the dependencies needed are not added by default.

To define strategies, just add their packages to your mix.exs file and add them to Ravenx configuration as follows:

config :ravenx,
  strategies: [
    email: Ravenx.Strategy.Email
    slack: Ravenx.Strategy.Slack
    my_strategy: MyApp.Ravenx.MyStrategy
  ]

We currently maintain two strategies:

Also, 3rd party strategies are supported and listed below.

3rd party strategies

Amazing people created 3rd party strategies to use Ravenx with more services:

Anyone can create a strategy that works with Ravenx, so if you have one, please let us know to add it to this list.

Custom strategies

Maybe there is some internal service you need to call to send notifications, so there is a way to create custom strategies for yout projects.

First of all, you need to create a module that meet the required behaviour, like the example you can see here.

Then you can define custom strategies in application configuration:

config :ravenx,
  strategies: [
    my_strategy: YourApp.MyStrategy
  ]

and start using your strategy to deliver notifications using the atom assigned (in the example, my_strategy).

Single notification

Sending a single notification is as simply as calling this method:

iex> Ravenx.dispatch(strategy, payload)

In which strategy is an atom indicating one of the defined strategies and the payload is a map with information to dispatch the notification.

For example:

iex> Ravenx.dispatch(:slack, %{title: "Hello world!", body: "Science is cool!"})

Optionally, a third parameter containing a map of options (like URLs or secrets) can be passed depending on strategy configuration needs.

Multiple notifications

You can implement notification modules that Ravenx can use to know which strategies should use to send a specific notification.

To do it, you just need to use Ravenx.Notification and implement a callback function:

defmodule YourApp.Notification.NotifyUser do
  use Ravenx.Notification

  def get_notifications_config(user) do
    # In this function you can define which strategies use for your user (or
    # whatever you want to pass as argument) and return something like:

    [
      slack: {:slack, %{title: "Important notification!", body: "Wait..."}, %{channel: user.slack_username}},
      email_user: {:email, %{subject: "Important notification!", html_body: "<h1>Wait...</h1>", to: user.email_address}},
      email_company: {:email, %{subject: "Important notification about an user!", html_body: "<h1>Wait...</h1>", to: user.company.email_address}},
      other_notification: {:invalid_strategy, %{text: "Important notification!"}, %{option1: value2}},
    ]
  end
end

As seen above, strategies can be used multiple times in a notification list (to send multiple e-mails that have different payload, for example).

Note: each notification entry in the returned list should include:

  1. Atom defining the notification ID.
  2. A two or three element tuple containing:
    1. Atom defining which strategy should be used.
    2. Payload map with the data of the notification.
    3. (Optional) Options map for that strategy.

And then you can dispatch your notification using:

iex> YourApp.Notification.NotifyUser.dispatch(user)

or asynchronously:

iex> YourApp.Notification.NotifyUser.dispatch_async(user)

Both will return a list with the responses for each notification sent:

iex> YourApp.Notification.NotifyUser.dispatch(user)
[
  slack: {:ok, ...},
  email_user: {:ok, ...},
  email_company: {:ok, ...},
  other_notification: {:error, {:unknown_strategy, :invalid_strategy}}
]

Configuration

Strategies usually needs configuration options. To solve that, there are three ways in which you can configure a notification dispatch strategy:

  1. Passing the options in the dispatch call:
iex> Ravenx.dispatch(:slack, %{title: "Hello world!", body: "Science is cool!"}, %{url: "...", icon: "🐦"})
  1. Specifying a configuration module in your application config:
config :ravenx,
  config: YourApp.RavenxConfig

and creating that module:

defmodule YourApp.RavenxConfig do
  def slack (_payload) do
    %{
      url: "...",
      icon: "🐦"
    }
  end
end

Note: the module should contain a function called as the strategy yopu are configuring, receiving the payload and returning a configuration Keyword list.

  1. Specifying the configuration directly on your application config file:
config :ravenx, :slack,
  url: "...",
  icon: "🐦"

Mixing configurations

Configuration can also be mixed by using the three methods:

  • Static configuration on application configuration.
  • Dynamic configuration common to more than one scenario using a configuration module.
  • Call-specific configuration sending a config Keyword list on dispatch method.

Contribute

All contributions are welcome, and we really hope this repo will serve for beginners as well for more advanced developers.

If you have any doubt, feel free to ask, but always respecting our Code of Conduct.

To contribute, create a fork of the repository, make your changes and create a PR. And remember, talking on PRs/issues is a must!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].