Skip to content

Instantly share code, notes, and snippets.

@seancdavis
Created December 7, 2015 12:55
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seancdavis/a2aa19d25cf60e9d95a9 to your computer and use it in GitHub Desktop.
Save seancdavis/a2aa19d25cf60e9d95a9 to your computer and use it in GitHub Desktop.
Post incoming webhook to Slack using Ruby
# Assumes:
# - curl is installed
# - you have a slack channel with an incoming webhook configured
require 'json'
def notify_slack(webhook_url, channel, username, text, image)
payload = {
:channel => channel,
:username => username,
:text => text,
:icon_url => image
}.to_json
cmd = "curl -X POST --data-urlencode 'payload=#{payload}' #{webhook_url}"
system(cmd)
end
@giladsh1
Copy link

awesome, thanks!

@shannonchou
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment