Skip to content

Instantly share code, notes, and snippets.

@jkronz
Last active November 3, 2015 17:33
Show Gist options
  • Save jkronz/fdd095300145fc6d6faa to your computer and use it in GitHub Desktop.
Save jkronz/fdd095300145fc6d6faa to your computer and use it in GitHub Desktop.
Cat Facts Slack Integration
class CatFact
def self.fact
response = Typhoeus.get("http://catfacts-api.appspot.com/api/facts")
JSON.parse(response.body)['facts'].first
end
end
def show
url = "https://yourteam.slack.com/services/hooks/incoming-webhook?token=#{some_api_token}"
response = Typhoeus.post(url, body: {"channel" => "##{params[:channel_name]}", "text" => CatFact.fact}.to_json)
render text: '', status: :ok
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment