PiperBot is a Slack bot written in Elixir. It connects to Slack’s real-time messaging API, reads the messages in the channels it’s in, and treats a message that starts with |> (Elixir’s pipe operator) as a list of commands. Each command is a category and an argument, like weather:<zip> or comic:xkcd, and one message can chain several: |> joke:random |> comic:xkcd tells a joke and then posts a comic.
The repository is a single commit from March 25, 2017, and its README is still the template Mix generates. Some of the services it called are gone. The Chuck Norris and random-joke APIs no longer answer, while xkcd’s JSON feed and the Ron Swanson quotes API still do.
Commands
weather:<zip>posts the current temperature for a five-digit US ZIP code from OpenWeatherMap, under a “Weather” name that includes the conditions.joke:randomtells a random joke.quote:chuck,quote:ron,quote:dwightandquote:michaelpost a quote under the character’s name and picture. The Chuck Norris and Ron Swanson quotes come from public APIs, and the Dwight Schrute and Michael Scott quotes are lists in the source.comic:xkcdposts a random xkcd strip as an attachment, andcomic:xkcd:todayposts the latest one.trello:login,trello:me,trello:assignedandtrello:assigned:randomconnect your Slack account to Trello and list your cards.help:alllists every command, andhelp:<category>lists one group.game:is a stub that echoes back whatever follows it.
Anything else gets “Didn’t understand that try |> help:all”. One trigger works without the pipe: any message containing “yeppers” gets a random Michael Scott quote.

> as >, so commands start with |>, and run_command parses them one at a time.![A code card of lib/piper_bot/help.ex, lines 4 to 43: Slack-formatted help text with sections for Trello, Weather, Jokes, Quotes and Comics, listing commands such as trello:login, weather:[:zipcode], joke:random, quote:chuck, quote:dwight, quote:michael, quote:ron, comic:xkcd and comic:xkcd:today with a short description of each.](/images/projects/piperbot-help.webp)
help:all posts all of it.Trello sign-in
trello:login sends you a direct message with a Trello authorization link. Trello returns the token in the URL fragment, which never reaches a server, so the return URL points at a small API that PiperBot runs with Maru on port 8880. That API serves a page whose script reads the fragment and calls /trello/auth/<user>/<token>, and the route stores the token in an Agent keyed by your Slack user ID.
After that, trello:me says who you’re signed in as, and trello:assigned fetches your cards and boards and posts each card as an attachment with its board, list, description and labels. The return URL is hardcoded to 127.0.0.1:8880, and the tokens live only in the Agent’s memory, so a restart forgets every sign-in.

How it’s built
PiperBot is an OTP application for Elixir 1.4. Its supervisor starts two workers: the bot process from Elixir-Slack 0.9, with PiperBot.Brain as its handler, and the Agent that holds Trello tokens. HTTPoison 0.9 and Poison 3 call the APIs and decode their JSON, Maru 0.10 serves the sign-in routes, and dotenv reads the Slack, OpenWeatherMap and Trello keys from a .env file. Most replies post under their own name and picture (Chuck Norris, xkcd, Trello and so on) rather than the bot’s.
A year later, Twitch Stream Cache was built from the same parts: Maru, HTTPoison, Poison and dotenv.
The creation date shown here is the GitHub repository’s UTC creation date. The images are code cards rendered from the repository’s source files, with their real line numbers.