{"id":15288824,"url":"https://github.com/tildeio/slackathon","last_synced_at":"2025-04-13T05:34:38.263Z","repository":{"id":56896077,"uuid":"111582563","full_name":"tildeio/slackathon","owner":"tildeio","description":"A simple way to build slack interations inside a Rails app.","archived":false,"fork":false,"pushed_at":"2024-03-20T22:25:37.000Z","size":29,"stargazers_count":31,"open_issues_count":11,"forks_count":8,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-11T15:14:24.932Z","etag":null,"topics":["rails","ruby","ruby-gem","ruby-on-rails","slack","slack-commands"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tildeio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-21T17:50:17.000Z","updated_at":"2023-03-16T16:26:30.000Z","dependencies_parsed_at":"2024-10-22T13:13:13.811Z","dependency_job_id":null,"html_url":"https://github.com/tildeio/slackathon","commit_stats":{"total_commits":5,"total_committers":3,"mean_commits":"1.6666666666666667","dds":0.4,"last_synced_commit":"a39f21796a567da2bd3c295eb87fce778bc8ace7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tildeio%2Fslackathon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tildeio%2Fslackathon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tildeio%2Fslackathon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tildeio%2Fslackathon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tildeio","download_url":"https://codeload.github.com/tildeio/slackathon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670518,"owners_count":21142896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rails","ruby","ruby-gem","ruby-on-rails","slack","slack-commands"],"created_at":"2024-09-30T15:53:19.179Z","updated_at":"2025-04-13T05:34:37.761Z","avatar_url":"https://github.com/tildeio.png","language":"Ruby","readme":"# Slackathon\n\nA simple way to build Slack interations inside a Rails app. Check out our\n[blog post](http://blog.skylight.io/the-slackathon) for the story behind\nthis gem!\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'slackathon'\n```\n\nAlso, add this to `config/routes.rb`\n\n```ruby\nmount Slackathon::Engine =\u003e \"/slack\"\n```\n\nAnd then execute:\n\n```bash\n$ bundle\n```\n\n## Development Workflow\n\n### Basic Slack Command\n\n1. Set up https://ngrok.com/\n\n   This gives you a public URL for Slack to reach your development machine.\n   On a Mac, you can also install it via `brew cask install ngrok`.\n\n   Assuming the Rails app is already running on port 3000, you can expose the\n   Rails app with `ngrok http 3000`, which should give you a public URL like\n   `http://00bea6f5.ngrok.io.`\n\n1. Create a Slack app at https://api.slack.com/apps\n\n   The \"App Name\" will be used as the display name when the app is replying to\n   commands.\n\n   To get everything working perfectly, you probably want to mirror all the\n   settings on the production app, the here are the most important bits.\n\n1. Go to \"Your App \u003e Settings \u003e Install App\" to add it to your Slack.\n\n1. Create your command under \"Your App \u003e Features \u003e Slash Commands\"\n\n   - The command is whatever you would type after the \"/\" in Slack, e.g.\n     `/monkey`.\n   - The request URL should be `http://00bea6f5.ngrok.io/slack/commands`.\n   - You probably want to turn on \"Escape channels, users, and links sent to\n     your app\" which will make it easier to parse @mentions and #channels.\n\n1. Create a `monkey_command.rb` in `app/slack`\n\n   - The name of the file (`monkey_command.rb`) and the class name (`MonkeyCommand`)\n     has to match the name of the command (`/monkey`).\n   - You should inherit from the `Slackathon::Command` class.\n   - You have access to the `params` hash.\n   - At minimum, you will need to implement the `call` method.\n   - Example:\n     ```ruby\n     class MonkeyCommand \u003c Slackathon::Command\n       def call\n         {\n           response_type: \"in_channel\",\n           text: \"#{user} said #{params[:text]} :see_no_evil:\"\n         }\n       end\n\n       private\n\n       def user\n         \"\u003c@#{params[:user_id]}\u003e\"\n       end\n     end\n     ```\n  - See https://api.slack.com/slash-commands#responding_to_a_command and\n    https://api.slack.com/docs/message-formatting for more documentation about\n    the responses you can send.\n\n### Adding Buttons\n\nIn this section, we will modify the `MonkeyBot` and let the user pick which\nmonkey emoji to use.\n\n1. Enable \"Your App \u003e Features \u003e Interactive Components\"\n\n   - This is required to support buttons, menus and dialogs.\n   - The request URL should be `http://00bea6f5.ngrok.io/slack/interactions`.\n   - You probably won't need to worry about \"Options Load URL\".\n\n1. Instead of immediately posting to the channel, we will reply to the user\n   only, asking for their emoji preference:\n\n   ```ruby\n   class MonkeyCommand \u003c Slackathon::Command\n     def call\n       {\n         response_type: \"ephemeral\",\n         attachments: [{\n           callback_id: \"monkey\",\n           text: \"Please pick a style\",\n           actions: [{\n             type: \"button\",\n             text: \"Click to use :see_no_evil:\",\n             name: \"post_in_channel\",\n             value: \"#{params[:text]} :see_no_evil:\"\n           }, {\n             type: \"button\",\n             text: \"Click to use :hear_no_evil:\",\n             name: \"post_in_channel\",\n             value: \"#{params[:text]} :hear_no_evil:\"\n           }, {\n             type: \"button\",\n             text: \"Click to use :speak_no_evil:\",\n             name: \"post_in_channel\",\n             value: \"#{params[:text]} :speak_no_evil:\"\n           }]\n         }]\n       }\n     end\n\n     def post_in_channel(value)\n       # do something with value, see below...\n     end\n   end\n   ```\n\n   - Here, we are using the `ephemeral` response type (as opposed to `in_channel`\n     as we did previously), which makes the response visible only to the user\n     who sent the command.\n   - In addition to the message text, we are including a few buttons in the\n     `attachments` array.\n   - The `callback_id` need to match the name of your command (e.g. `monkey` in\n     this case).\n   - The `actions` array has the button(s) you want to include.\n   - The `text` is the label of the button (e.g. \"Click me!!!\").\n   - The `name` is the name of the method to call when the button is clicked\n     (see below).\n   - The `value` is an optional string that will be passed to the method (see\n     below).\n   - See https://api.slack.com/interactive-messages and https://api.slack.com/dialogs\n     for more documentation.\n\n1. When the user clicks on one of the buttons, it will call the method you\n   specified:\n\n   ```ruby\n   class MonkeyCommand \u003c Slackathon::Command\n     # def call ...\n     def post_in_channel(value)\n       {\n         response_type: \"in_channel\",\n         delete_original: true,\n         text: \"\u003c@#{params[:user][:id]}\u003e said #{value}\"\n       }\n     end\n   end\n   ```\n\n   Here, `value` is the string that we attached to the original buttons.\n\n## Promoting to Production\n\n1. Remove the command from your development Slack app.\n\n1. Create a production Slack app and your command/interactive component\n   following the instructions above (with the URLs pointing to your\n   production Rails app).\n\n1. Find the \"Verification Token\" from `https://api.slack.com/apps/\u003cyour app\u003e`.\n   Assign its value to the `SLACK_VERIFICATION_TOKEN` ENV variable in\n   your production environment (or set it with `Slackathon.verification_token = ...`).\n\n1. Make sure your Active Job adapter is configured to process the `slack`\n   queue (e.g. `bundle exec sidekiq -q default -q slack ...`). Alternatively,\n   you can change the queue with `Slackathon.queue = ...`.\n\n1. Deploy your changes!\n\n## License\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftildeio%2Fslackathon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftildeio%2Fslackathon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftildeio%2Fslackathon/lists"}