Awesome
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
- Create a new app here
- Navigate to the OAuth & Permissions page and add the following Bot Token Scopes:
users:read
channels:read
groups:read
chat:write
commands
incoming-webhook
BASE_URL stands for https://slackbot-hosted-domain.com hereafter. Use BASE_URL for Redirect.
- Activate Interactivity & Shortcuts and add this url:
BASE_URL/api/slack/action
- Activate Slash Commands adding two slash commands
/ping
,/quiz
and use this url:BASE_URL/api/slack/command
- 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) - 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!
- Fork the project (https://docs.github.com/en/get-started/quickstart/fork-a-repo)
- Create your own branch with a meaningful name
- Install dependencies by running
bundle install
- Make changes and push your commits
- Create a pull request
- Add a PR description explaining what it is for.
Credit
This boilerplate uses Slack Ruby Bot Server Events.
Thanks to Daniel Doubrovkine and all the contributors.
Made with :heart: by crazyoptimist