Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
chat.postMessage sample for Slack
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
You can’t perform that action at this time.