8000 GitHub - hashrocket/slack-command-api: A Sinatra API for processing custom Slack commands
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

hashrocket/slack-command-api

Repository files navigation

Slack Command API Deploy

This Sinatra API converts custom Slack commands into Bot messages. The API will post to your current channel by default, but you can specify a channel: /late 10AM #another_channel

Example: A /late 10AM command converts to a text response Hey team, I'm gonna be in around 10AM.

Dependencies

  • RVM
  • Sinatra
  • Testing: RSpec

Getting Started

  1. git clone the app
  2. cd into the folder.
  3. Bundle the gems. bundle install
  4. Set your Slack webhook environment variable. Create a .env file. Populate it with a SLACK_URL variable for your app's incoming webhook.
  5. Run the app with bundle exec passenger start

Adding a New Command in 2 steps

Create a message object that constructs a message, gives the bot a name, and gives it an emoji.

class YourCommandMessage

  def construct_message(text, user_name)
    "This text will show up in Slack and can show the #{user_name} of who issued the command, along the #{text} of the command"
  end

  # Your bot will be named 'Your-Command-Bot'
  def bot_name
    'Your-Command-Bot'
  end

  # This will show a whale icon for your chat bot
  def icon_emoji
   ':whale:'
  end
end

Add a post url to app.rb

# ...
require_relative 'your_command_message'
# ...
post '/your_command_url' do
  response = Response.new(params, YourCommandMessage.new)
  Slack.new(response).post
end
# ...

Done.

Testing

  1. Head to the spec folder. cd spec
  2. Run the tests with rspec --color --format documentation

Credits

Maintainer: Joshua Plicque If you have any questions, send me a tweet.

About

A Sinatra API for processing custom Slack commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages

0