85
102

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Microsoft Teamsにメッセージを飛ばす

Last updated at Posted at 2017-05-01

Incoming Webhookで通知を飛ばします

Incoming Webhookの設定

公式の説明に則ってkeyを取得します

  1. Teamsのチームを選択

  2. チャンネルを右クリックして「コネクタ」を選択

    • teams.png
  3. 「Incoming Webhook」を選択し、アカウントを作成する

    • 既に追加している場合は「構成済み」からたどれます
  4. URLをコピーしておく

curlで投げる

これも公式の設定に則って投げます

echo '{"text": "Hello World!"}' | curl -H 'Content-type: application/json' -d @- <YOUR WEBHOOK URL>

notice.png

タイトルを付与したり、リンクを投げることもできます
詳しいドキュメント

echo '{"text": "[Hubot-Slackの表示をリッチにする](http://qiita.com/miyay/items/c436b6ec46f61a4d6e72)", "title": "今日のQiitaのホットエントリよ!"}' | curl -H 'Content-type: application/json' -d @- <YOUR WEBHOOK URL>

notice_with_title.png

今のところメンションは効かないみたいです

Rubyで投げる

POSTできれば良いので、なんでも

def post_teams(url, mes)
  uri = URI.parse(url)
  request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})
  request.body = {text: mes}.to_json

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  http.start {|h| response = h.request(request) }
end

post_teams("<YOUR WEBHOOK URL>", "Hello World!")
85
102
2

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
85
102

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?