dfeuerbach

dfeuerbach

SlackBot WS – an OTP-first Socket Mode framework for Slack bots

Reconnects. Backoff. Heartbeats. Slack’s per-method rate limit. Traffic shaping. SlackBot WS handles all of it—and makes building a bot feel like the reason you picked Elixir. This is not a thin API wrapper; it’s an OTP-first Socket Mode runtime.

For slash commands, you declare your command grammar—no regexes or nested conditionals. SlackBot compiles it into a parser at build time.

defmodule MyApp.SlackBot do
  use SlackBot, otp_app: :my_app

  # /deploy api        → %{service: "api"}
  # /deploy api canary → %{service: "api", canary?: true}
  slash "/deploy" do
    grammar do
      value :service
      optional literal("canary", as: :canary?)
    end

    handle payload, _ctx do
      Deployments.kick(payload["parsed"].service)
    end
  end
end

Slash commands aren’t the only thing routed this way. Event handlers work the same:

handle_event "app_mention", event, _ctx do
  SlackBot.push(MyApp.SlackBot, {"chat.postMessage", %{
    channel: event["channel"],
    text: "Hi <@#{event["user"]}>!"
  }})
end

SlackBot WS handles the tier limits and throttling for you.

And middleware works the way you’d expect if you’re familiar with Plug—just over Slack events instead of HTTP.

defmodule MyApp.LogMiddleware do
  def call(_type, payload, ctx) do
    Logger.debug("Slack event: #{payload["type"]}")
    {:cont, payload, ctx}
  end
end

middleware MyApp.LogMiddleware

Return {:cont, payload, ctx} to continue, {:halt, response} to short-circuit.

That’s it. Add your API tokens, supervise the module, ship.

The defaults are production-ready. ETS for cache and event buffer. Sensible backoff. Rate limiting on. You can swap cache adapters if you want to go multi-node, tune timeouts, wire up Telemetry dashboards—but you don’t have to touch any of it until you need to.

SlackBot WS is an extraction of something else I’m building, and I want to share it with those who just want to write Slack bots without the Slack complexity—be they one-off utilities or large bots. Maybe that’s you.

https://github.com/dfeuerbach/slack_bot_ws

Most Liked

dfeuerbach

dfeuerbach

Thanks, Ostap. It really is a shame. I can envision a handful of historical reasons why that is (not built on the BEAM being one :slight_smile:). That said, this is an extraction of a more sophisticated HTTP-event driven framework I’m building, and may release some version of it.

Where Next?

Popular in Announcing Top

josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 19228 141
New
gabrielpoca
Hello everyone! I want to share with you something that I’m really proud of: https://stillstatic.io/ Still is a static site builder for...
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New
josevalim
Hello everyone, We have just released NimbleCSV which is a small and fast CSV parsing library for Elixir. It allows developers to define...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
New

Other popular topics Top

chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

We're in Beta

About us Mission Statement