Git Product home page Git Product logo

slack-rails-bot-starter's Introduction

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

slack-rails-bot-starter's People

Contributors

aprilrieger avatar crazyoptimist avatar dblock avatar msuliq avatar rofreg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

slack-rails-bot-starter's Issues

Needs tests & CI

This project needs tests and CI. I was debugging #6 and am not sure that what I'm doing isn't breaking everything.

Weird error?

Hiya! I'm getting a weird error (see below). Any ideas on how I could go about debugging it?
(I am using Rails 3.0.1, but I get the same error with Rails 2.7.2)

➜ rails s
Traceback (most recent call last):
        57: from bin/rails:4:in `<main>'
        56: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        55: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        54: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        53: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        52: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        51: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.7/lib/rails/commands.rb:18:in `<main>'
        50: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.7/lib/rails/command.rb:46:in `invoke'
        49: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.7/lib/rails/command/base.rb:69:in `perform'
        48: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        47: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
        46: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
        45: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.7/lib/rails/commands/server/server_command.rb:138:in `perform'
        44: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.7/lib/rails/commands/server/server_command.rb:138:in `tap'
        43: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.7/lib/rails/commands/server/server_command.rb:141:in `block in perform'
        42: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        41: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        40: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        39: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        38: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        37: from /Users/dharmon/Development/CMM/cipherbot/config/application.rb:20:in `<main>'
        36: from /Users/dharmon/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler.rb:174:in `require'
        35: from /Users/dharmon/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
        34: from /Users/dharmon/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
        33: from /Users/dharmon/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require'
        32: from /Users/dharmon/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each'
        31: from /Users/dharmon/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require'
        30: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        29: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        28: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        27: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        26: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        25: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/slack-ruby-bot-server-1.1.0/lib/slack-ruby-bot-server.rb:13:in `<main>'
        24: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
        23: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        22: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        21: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        20: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        19: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        18: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/slack-ruby-bot-server-1.1.0/lib/slack-ruby-bot-server/api.rb:7:in `<main>'
        17: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
        16: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        15: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        14: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        13: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        12: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        11: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/slack-ruby-bot-server-1.1.0/lib/slack-ruby-bot-server/api/presenters.rb:7:in `<main>'
        10: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
         9: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
         8: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
         7: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
         6: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
         5: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
         4: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/slack-ruby-bot-server-1.1.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:1:in `<main>'
         3: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/slack-ruby-bot-server-1.1.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:2:in `<module:SlackRubyBotServer>'
         2: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/slack-ruby-bot-server-1.1.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:3:in `<module:Api>'
         1: from /Users/dharmon/.rvm/gems/ruby-2.7.2/gems/slack-ruby-bot-server-1.1.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:4:in `<module:Presenters>'
/Users/dharmon/.rvm/gems/ruby-2.7.2/gems/slack-ruby-bot-server-1.1.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:13:in `<module:TeamPresenter>': uninitialized constant SlackRubyBotServer::Api::Presenters::TeamPresenter::Boolean (NameError)

Best way to create Team model

I'm trying to get this repo set up, but I'm getting stuck on creating the Teams model for the database (I'm using pg for this). When I run the server and try to add it to a workspace, I get this:

ERROR -- : ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "teams" does not exist

Trying something like rails g model Team warns me that The name 'Team' is either already used in your application or reserved by Ruby on Rails.

This makes sense, but I'm not sure how to reconcile the two messages. I've never really used Grape, so I imagine I'm just missing something simple. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.