Last active
November 27, 2015 20:24
-
-
Save polamjag/66783675ca14623e98ca to your computer and use it in GitHub Desktop.
Slack Incoming Webhook in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'uri' | |
require 'json' | |
# param `data` will be like this (only `text` is mandatory) | |
# { | |
# channel: '#general', | |
# username: 'somebot', | |
# text: 'hello world!' | |
# } | |
def webhook(hook_url, data={}) | |
uri = URI.parse(hook_url) | |
Net::HTTP.post_form( | |
uri, | |
{ payload: data.to_json } | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment