10
10

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 5 years have passed since last update.

pythonでslackに通知する方法まとめ

Posted at

環境

python3.6

やりかた1(Webhook)

もっとも簡単な方法は、slackチャンネルのWebhook URLを取得してrequestsモジュールでPOSTする方法
こちらの記事を参考にしました。

simple.py
import requests
import json

# webhookURLを指定
webhook_url = "自分のチャットルームのWebhookURL"

# 送信するテキストを定義
text = "PythonでSlackにメッセージを送る"

# Slackに送信する
requests.post(webhook_url, data = json.dumps({
	"text": text
}))

やりかた2(app経由)

slack apiのappを作って、権限設定しつつ、appからメッセージ&画像送信
以下の記事の順で参考にして進めていきました。
token取得
コード

10
10
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
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?