LoginSignup
34
34

More than 5 years have passed since last update.

Slack の incoming WebHook で post する簡単なサンプル

Posted at

https://${チーム名}.slack.com/services/new で Incoming WebHooks を追加し,
path をコピーする.

slack.rb
require 'net/http'
require 'uri'
require 'json'

def post(text)
  data = {
    "text" => text
  }
  request_url = "https://${チーム名}.slack.com/services/hooks/incoming-webhook?token=${トークンキー}"
  uri = URI.parse(request_url)
  http = Net::HTTP.post_form(uri, {"payload" => data.to_json})  
end

post("test")
34
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
34