Skip to content

Commit d0f3fcd

Browse files
author
Sarath Kaul
committed
Slack Webhook Script Added
1 parent e60a473 commit d0f3fcd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

slack_message.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Created by sarathkaul on 11/11/19
2+
3+
import json
4+
import requests
5+
6+
# Set the webhook_url to the one provided by Slack when you create the webhook at https://my.slack.com/services/new/incoming-webhook/
7+
webhook_url = 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
8+
slack_data = {'text': "Hi Sarath Kaul"}
9+
10+
response = requests.post(webhook_url, data=json.dumps(slack_data),headers={'Content-Type': 'application/json'})
11+
if response.status_code != 200:
12+
raise ValueError(
13+
'Request to slack returned an error %s, the response is:\n%s'
14+
% (response.status_code, response.text)
15+
)

0 commit comments

Comments
 (0)