Skip to content

crazyoptimist/slack-rails-bot-starter

Repository files navigation

Slack Rails Bot Starter

This is a boilerplate for building slack apps with Ruby on Rails.

The default branch master uses Mongoid as database adapter. For ActiveRecord, please check postgres branch.

Setup

Prerequisites

  • FQDN(Fully Qualified Domain Name) to host the app publicly. You can also choose to use ngrok instead.

Create a New Slack App

  1. Create a new app here
  2. Navigate to the OAuth & Permissions page and add the following Bot Token Scopes:
  1. Activate Interactivity & Shortcuts and add this url: BASE_URL/api/slack/action
  2. Activate Slash Commands adding two slash commands /ping, /quiz and use this url: BASE_URL/api/slack/command
  3. Activate Event Subscriptions subscribing to the event type member_joined_channel and add this url: BASE_URL/api/slack/event(This step needs the application to be running :D so you can skip this and come back a few mins later)
  4. Navigate to the App Home page and toggle Always Show My Bot as Online (according to your reference)

Install Dependencies and Create a .env File

bundle install
cp .env.example .env

Go to https://api.slack.com/apps, click on your application.

Checkout what's needed for .env from the Basic Information section.

Run the App

rails s

Open BASE_URL in your browser.

Learn More About Slack Apps with Ruby

Deployment

Please follow the standard Ruby on Rails application deployment methods.

Contributing

Thanks in advance for your contribution!

Credit

This boilerplate uses Slack Ruby Bot Server Events.

Thanks to Daniel Doubrovkine and all the contributors.

Made with ❤️ by crazyoptimist