Created
October 28, 2016 06:48
-
-
Save shoyan/770dacc2048107e794c167fff4471605 to your computer and use it in GitHub Desktop.
chat.postMessage sample for Slack
This file contains 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
require "faraday" | |
username = 'your name' | |
channel = 'your channel' | |
slack_token = 'your slack token' | |
icon_url = 'your icon url' | |
body = { | |
username: username, | |
channel: channel, | |
icon_url: icon_url, | |
text: "Hello world" | |
} | |
Faraday.new('https://slack.com') do |c| | |
c.request :url_encoded | |
c.adapter Faraday.default_adapter | |
end.post("/api/chat.postMessage?token=#{slack_token}", body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment