Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Show comment
Hide comment
@giladsh1

giladsh1 Sep 24, 2017

awesome, thanks!

giladsh1 commented Sep 24, 2017

awesome, thanks!

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