Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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 =
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
You can’t perform that action at this time.