I am still working on picking up some elixir, so when a coworker mentioned that writing a Slack bot is cool, I decided to give that a try. Slack is a bit easier to work with than IRC because the communication is done in JSON so you can skip a step in message parsing.
The login process for a slack bot is:
- Authenticate over HTTP using your bot’s token.
- Open a websocket connection using the socket url returned in 1.
- Communicate using JSON over the socket.
Each of these steps required importing a library (:httpotion
, "meh/elixir-socket"
, and :poison
).
This is a bit of a departure from go where the standard library has HTTP and JSON support, and
there’s an x-package for websockets. But everything
worked well. It’s three external dependencies instead of two.
Elixir does have a package repository, so it’s way ahead of go in that regard.
You can take a look at my slack bot here.