{"id":13878218,"url":"https://github.com/slack-ruby/slack-ruby-bot-server-events","last_synced_at":"2025-07-16T14:31:47.665Z","repository":{"id":43021978,"uuid":"280467230","full_name":"slack-ruby/slack-ruby-bot-server-events","owner":"slack-ruby","description":"Slack commands, interactive buttons, and events extension for slack-ruby-bot-server.","archived":false,"fork":false,"pushed_at":"2023-03-20T15:51:20.000Z","size":47,"stargazers_count":71,"open_issues_count":5,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-07T04:23:52.084Z","etag":null,"topics":[],"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/slack-ruby.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"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":"2020-07-17T15:59:40.000Z","updated_at":"2024-08-16T21:55:24.000Z","dependencies_parsed_at":"2024-06-19T06:29:44.286Z","dependency_job_id":null,"html_url":"https://github.com/slack-ruby/slack-ruby-bot-server-events","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-ruby%2Fslack-ruby-bot-server-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-ruby%2Fslack-ruby-bot-server-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-ruby%2Fslack-ruby-bot-server-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slack-ruby%2Fslack-ruby-bot-server-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slack-ruby","download_url":"https://codeload.github.com/slack-ruby/slack-ruby-bot-server-events/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"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":[],"created_at":"2024-08-06T08:01:43.041Z","updated_at":"2024-11-24T07:30:51.728Z","avatar_url":"https://github.com/slack-ruby.png","language":"Ruby","readme":"Slack Ruby Bot Server Events Extension\n======================================\n\n[![Gem Version](https://badge.fury.io/rb/slack-ruby-bot-server-events.svg)](https://badge.fury.io/rb/slack-ruby-bot-server-events)\n[![lint](https://github.com/slack-ruby/slack-ruby-bot-server-events/actions/workflows/rubocop.yml/badge.svg)](https://github.com/slack-ruby/slack-ruby-bot-server-events/actions/workflows/rubocop.yml)\n[![test with mongodb](https://github.com/slack-ruby/slack-ruby-bot-server-events/actions/workflows/test-mongodb.yml/badge.svg)](https://github.com/slack-ruby/slack-ruby-bot-server-events/actions/workflows/test-mongodb.yml)\n[![test with postgresql](https://github.com/slack-ruby/slack-ruby-bot-server-events/actions/workflows/test-postgresql.yml/badge.svg)](https://github.com/slack-ruby/slack-ruby-bot-server-events/actions/workflows/test-postgresql.yml)\n\nAn extension to [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server) that makes it easy to handle Slack slash commands, interactive buttons and events.\n\n### Table of Contents\n\n- [Sample](#sample)\n- [Usage](#usage)\n  - [Gemfile](#gemfile)\n  - [Configure](#configure)\n    - [OAuth](#oauth)\n    - [Events](#events)\n  - [Implement Callbacks](#implement-callbacks)\n  - [Events](#events-1)\n  - [Actions](#actions)\n  - [Commands](#commands)\n- [Copyright \u0026 License](#copyright--license)\n\n### Sample\n\nSee [slack-ruby/slack-ruby-bot-server-events-sample](https://github.com/slack-ruby/slack-ruby-bot-server-events-sample) for a working sample.\n\n### Usage\n\n#### Gemfile\n\nAdd 'slack-ruby-bot-server-events' to Gemfile.\n\n```ruby\ngem 'slack-ruby-bot-server-events'\n```\n\n#### Configure\n\n##### OAuth\n\nConfigure your app's [OAuth version](https://api.slack.com/authentication/oauth-v2) and [scopes](https://api.slack.com/legacy/oauth-scopes) as needed by your application.\n\n```ruby\nSlackRubyBotServer.configure do |config|\n  config.oauth_version = :v2\n  config.oauth_scope = ['users:read', 'channels:read', 'groups:read', 'chat:write', 'commands', 'incoming-webhook']\nend\n```\n\n##### Events\n\nConfigure events-specific settings.\n\n```ruby\nSlackRubyBotServer::Events.configure do |config|\n  config.signing_secret = 'secret'\nend\n```\n\nThe following settings are supported.\n\nsetting               | description\n----------------------|------------------------------------------------------------------\nsigning_secret        | Slack signing secret, defaults is `ENV['SLACK_SIGNING_SECRET']`.\nsignature_expires_in  | Signature expiration window in seconds, default is `300`.\n\nGet the signing secret from [your app's](https://api.slack.com/apps) _Basic Information_ settings.\n\n#### Implement Callbacks\n\nThis library supports events, actions and commands. When implementing multiple callbacks for each type, the response from the first callback to return a non `nil` value will be used and no further callbacks will be invoked. Callbacks receive subclasses of [SlackRubyBotServer::Events::Requests::Request](lib/slack-ruby-bot-server-events/requests/request.rb).\n\n#### Events\n\nRespond to [Slack Events](https://api.slack.com/events-api) by implementing `SlackRubyBotServer::Events::Config#on :event`.\n\nThe following example unfurls URLs.\n\n```ruby\nSlackRubyBotServer::Events.configure do |config|\n  config.on :event, 'event_callback', 'link_shared' do |event|\n    event[:event][:links].each do |link|\n      Slack::Web::Client.new(token: ...).chat_unfurl(\n        channel: event[:event][:channel],\n        ts: event[:event][:message_ts],\n        unfurls: {\n          link[:url] =\u003e { text: 'Unfurled URL.' }\n        }.to_json\n      )\n    end\n\n    true # return true to avoid invoking further callbacks\n  end\n\n  config.on :event, 'event_callback' do |event|\n    # handle any event callback\n    false\n  end\n\n  config.on :event do |event|\n    # handle any event[:event][:type]\n    false\n  end\nend\n```\n\n\n#### Actions\n\nRespond to [Shortcuts](https://api.slack.com/interactivity/shortcuts) and [Interactive Messages](https://api.slack.com/messaging/interactivity) as well as [Attached Interactive Message Buttons(Outmoded)](https://api.slack.com/legacy/message-buttons) by implementing `SlackRubyBotServer::Events::Config#on :action`.\n\nThe following example posts an ephemeral message that counts the letters in a message shortcut.\n\n```ruby\nSlackRubyBotServer::Events.configure do |config|\n  config.on :action, 'interactive_message', 'action_id' do |action|\n    payload = action[:payload]\n    message = payload[:message]\n\n    Faraday.post(payload[:response_url], {\n      text: \"The text \\\"#{message[:text]}\\\" has #{message[:text].size} letter(s).\",\n      response_type: 'ephemeral'\n    }.to_json, 'Content-Type' =\u003e 'application/json')\n\n    { ok: true }\n  end\n\n  config.on :action do |action|\n    # handle any other action\n    false\n  end\nend\n```\n\nThe following example responds to an interactive message.  \nYou can compose rich message layouts using [Block Kit Builder](https://app.slack.com/block-kit-builder).\n\n```ruby\nSlackRubyBotServer::Events.configure do |config|\n  config.on :action, 'block_actions', 'your_action_id' do |action|\n    payload = action[:payload]\n\n    Faraday.post(payload[:response_url], {\n      text: \"The action \\\"your_action_id\\\" has been invoked.\",\n      response_type: 'ephemeral'\n    }.to_json, 'Content-Type' =\u003e 'application/json')\n\n    { ok: true }\n  end\nend\n```\n\n#### Commands\n\nRespond to [Slash Commands](https://api.slack.com/interactivity/slash-commands) by implementing `SlackRubyBotServer::Events::Config#on :command`.\n\nThe following example responds to `/ping` with `pong`.\n\n```ruby\nSlackRubyBotServer::Events.configure do |config|\n  config.on :command, '/ping' do\n    { text: 'pong' }\n  end\n\n  config.on :command do |command|\n    # handle any other command\n    false\n  end\nend\n```\n\n### Copyright \u0026 License\n\nCopyright [Daniel Doubrovkine](http://code.dblock.org) and Contributors, 2020\n\n[MIT License](LICENSE)\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslack-ruby%2Fslack-ruby-bot-server-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslack-ruby%2Fslack-ruby-bot-server-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslack-ruby%2Fslack-ruby-bot-server-events/lists"}