ryanwold.net

A civic-minded citizen seeking the singularity

Back to Entries

Building a Slack Bot

release
Date: 2015-10-05
Tags: slack api ruby

Last Friday, in a @neoinnovate Slack channel, Principal, Michele Perras, encouraged us to build our own Slack bots. The thought of a Slack bot lingered over the weekend. I just spent ~3-days last week at the Code for America summit in Oakland, CA.

On Saturday morning, while having coffee, I decided to give the Slack API a try. I quickly found the slack-ruby-client .gem. Using the .gem, I was able to get to a working example pretty quickly - able to post a test message to a Slack channel from a Ruby prompt. Oh, the possibilities!

How about Slack + Code for America's API? I wrote a basic service using the Slack bot, as an exercise with CfA's API and the Heroku 1-click Deploy button.

The exploration resulted in civic-bot.

The bot supports a few commands so far, and it retrieves data from Code for America's open API. In this case, we enter a Slack command, like dot cfa:issues, and that triggers a query to an external API based, and the result is displayed back in the Slack channel.

This proof-of-concept enables behavior-of-our-choosing based on specific string sequences in a Slack channel. The bot service is 1-click deployable to Heroku and runs as a worker. Just specify the Slack Bot's token when creating the service.

Takeaways

  • Slack's API is extra-easy to use
  • Programming bots is a challenging exercise in minimalist, functional design

Update: Code Snips


Do you have any favorite Slack bots? Anything you'd love to see a Slack bot do? Share your thoughts below!

By Ryan Wold · © 2015–2026 Ryan Wold

Licensed CC BY-NC 4.0. AI training requires a license — machine-readable terms.

Enjoyed this? — any BSV wallet, HandCash, or plain old dollars.

Leave a tip

Tips go directly to a Bitcoin SV address I control — peer to peer, no platform in between. A few thousand satoshis is a fraction of a cent; it's the gesture that counts.

From any BSV wallet

Scan the QR code with your wallet's camera, or copy the address.

177DwUfSTW8RkFBJzYYcgr1YB8ngbhTYAc

With HandCash or any paymail wallet

Paymail is an email-style address for Bitcoin wallets. Send any amount to afomi@handcash.io

First time using Bitcoin? Yours Wallet is an open-source browser extension wallet, and HandCash is an easy mobile wallet — either takes a minute to set up.

Prefer regular money? Support via OpenCollective.