axelson

axelson

Scenic Core Team

How would you implement Slack's notification flowchart in Elixir?

Slack has a crazy/intense flowchart to decide if they should send a push notification to a user for a specific message. Here it is for reference:

[source]

As a thought experiment if you were tasked with creating a system in Elixir to implement this decision tree how would you implement it? Ideally the approaches would take into consideration:

  • Maintainability of the code
  • Clarity/readability (bonus points if it can easily be shown to the business owner)
  • The understanding that answering some of the questions in the flowchart may require a non-negligible db query

Most Liked

gregvaughn

gregvaughn

There was a talk at this year’s ElixirConf about Behavior Trees that might be applicable here. They’re a concept mostly from the video game industry and NPC behavior. They were new to me, but might be worth watching the talk to see if you’d want to try them for this.

10
Post #3
slashdotdash

slashdotdash

I’ve just discovered a library named Opus which allows you to create pipelines using a declarative DSL. It even supports outputting a pipeline as a graph using GraphVix.

sanswork

sanswork

I’d create a module with a single entry point and all the rules as private functions within it, pattern matching where possible. In a roughly top down order.

def send_notification(user, message)

#called from send_notifications
defp channel_muted(user, message)

#called from channel_muted
defp message_and_subscribed(user, message)

I don’t see any way to get something with that complex of a flow in a way that could easily be shown to a business owner in code so I wouldn’t put much energy into trying since a flow chart like this is a better route for that. I’d focus exclusively on trying to get it to be easy for developers to slot in new rules. So things like making sure comments show all calling functions.

Where Next?

Popular in Discussions Top

matthias_toepp
I’d love to hear what people think about Wisp, the new Gleam web framework started by Gleam’s primary creator Louis Pilfold. Gleam, alon...
New
mikl
I wanted to capitalize a string, and tried using String.capitalize(). That generally works well, until you try to capitalize a word like...
New
jeramyRR
This is an interesting article to read. Elixir’s performance, like usual, is excellent. However, it seems like the high CPU usage is co...
New
Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New
crabonature
I’m still quite new to Elixir. As I understand we got in Elixir “multi guards” as convention to simplify one large guard with or’s?: de...
New
tmbb
This is a post to discuss the new Phoenix LiveView functionality. From Chris’s talk, it appears that they generate all HTML on the serve...
342 18146 126
New
hazardfn
I suppose this question is effectively hackney vs. ibrowse but we are at a point in our project where we have to make a choice between th...
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
joeerl
I’m playing with Elixir - It’s fun. I think @rvirding does give Elixir courses these days. Re: files and database - when I given Erlang ...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement