Skip to content

Instantly share code, notes, and snippets.

@s9k96
Created July 13, 2020 06:32
Show Gist options
  • Save s9k96/06ded6d32f2d003840dc7f6208235301 to your computer and use it in GitHub Desktop.
Save s9k96/06ded6d32f2d003840dc7f6208235301 to your computer and use it in GitHub Desktop.
Send notifications to a slack channel through slack webhooks.
# Send notifications to a slack channel through slack webhooks.
import requests
import json
webhook = '' # Slack channel webhook.
def notify_slack(message):
"""
Send a string to slack channel.
message: str
"""
data= {
'text' : message
}
try:
requests.post(webhook, json.dumps(data))
except:
print("[ERROR] Not able to execute slack notification.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment