Send Slack message with web-hooks on Python
import json | |
import requests | |
webhook_url = "" #Add the webhook here | |
slack_data = {"text": "This is a test message", "channel": "<channel-name> or <@person>"} | |
response = requests.post( | |
webhook_url, data = json.dumps(slack_data), | |
headers={'Content-Type': 'application/json'} | |
) | |
if response.status_code != 200: | |
raise ValueError( | |
'Request to slack returned an error %s, the response is:\n%s' | |
% (response.status_code, response.text) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment