odarriba

odarriba

Ravenx

Hex: https://hex.pm/packages/ravenx
GitHub: https://github.com/acutario/ravenx

Ravenx is a notification dispatcher that allows to simplify the sending of notifications to external services, even if you need to send them using multiple providers.

The library has two main methods: the dispatch that returns the final state of the process and dispatch_async which just returns the reference of the %Task{} without waiting the response.

Each notification is defined by three thinhs: the strategy (or service) to use, the payload map (which contains the data used to build the notification) and the options map, which include configuration for the service provider, or similar.

In case you need to notify something using multiple methods (or strategies), you can create a Notification module that specify each notification sent.

Example of simple notification

You can just send a notification synchronously:

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

Or asynchronously:

{:ok, %Task{}} = Ravenx.dispatch_async(:slack, %{title: "Hello world!", body: "Science is cool!"})

Example of complex notification

Given this example notification module:

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

You can just tell Ravenx to dispatch it synchronously:

YourApp.Notification.NotifyUser.dispatch(user)

And it will spawn the different processes and return the response for each in just one call:

[
  slack: {:ok, ...},
  email_user: {:ok, ...},
  email_company: {:ok, ...},
  other_notification: {:error, {:unknown_strategy, :invalid_strategy}}
]

First 7 of 7 Posts Switch mode

odarriba

odarriba OP

Just published a blog post about how to use Ravenx and why we built this library:

https://medium.com/acutario/sending-notifications-in-elixir-with-ravenx-1f2502a1f272

belaustegui

belaustegui

Wonderful! :raised_hands:

agustif

agustif

It looks great, Guys, do you think ravenx could fit well for connecting with Zapier?

At cercle crm we want to send notifications via zapier, and I thought about this as a good way to leave the door open to new integrations down the road.

odarriba

odarriba OP

It should not be complicated to integrate it with any external services.

The only thing you need to do is to create a custom strategy (GitHub - acutario/ravenx: Notification dispatch library for Elixir applications · GitHub) to communicate with the service.

If you decide to do it, please feel free to create an auxiliary library or put a PR, so others can make use of it!

odarriba

odarriba OP

After some inactive months, we have just released version 2.0.0 of Ravenx.

The major changes are:

  • Simpler supervision tree
  • Code formatter applied to the src
  • Strategies now are in separate packages (except the dummy one)
  • Minor fixes

Special mention to the fact that strategies now are in different packages, avoiding additional dependencies for strategies that you are not going to use (like Bamboo).

How to upgrade

Just upgrade version, and add the packages of needed strategies. Then add the strategies to the application configuration as indicated in the README. And you are good to go!

belaustegui

belaustegui

Been using Ravenx by 6 months (more or less) in production delivering websocket and email notifications without any problem.
Can’t wait to update to the next release! :bow:

brightball

brightball

Looks really sharp!

— All posts loaded —

Where Next? Top

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 15136 120
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
woylie
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto. pagination cursor pagination sorta...
New
kip
Please say hi to a new lib, Astro that aims to deliver easy-to-consume astronomy calculations of practical use. For now it only calculat...
New

Other Trending Topics Top

akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

We're in Beta

About us Mission Statement