Daniel Doubrovkine bio photo

Daniel Doubrovkine

aka dB., @awscloud, former CTO @artsy, +@vestris, NYC

Email Twitter LinkedIn Github Strava
Creative Commons License

I’ve extracted and improved upon common code from slack-gamebot and slack-mathbot and made slack-ruby-bot. It’s probably the easiest way to make a Slack bot in Ruby today.

Here’s a minimal example.

require 'slack-ruby-bot'

class PongBot < SlackRubyBot::Bot
  command 'ping' do |client, data, _|
    client.say(channel: data.channel, text: 'pong')
  end
end

PongBot.run

Add gem 'slack-ruby-bot' to your Gemfile and party on. Unlike Lita it’s not trying to be anything other than a Slack bot boilerplate. Source code on Github.

Update: Integration with Rails

If you’re trying to integrate Slack with Rails, check out Writing a Slack Bot running on Rails (with React).