Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python Requests Post Slack Message
"""
https://api.slack.com/incoming-webhooks#sending_messages
{
"text":"Read <https://api.slack.com/incoming-webhooks#sending_messages|Send Slack Message> for more details @slackuser #general"
"link_names": 1
}
"""
import requests,json
def slack_message(message_text=None,payload_obj=None,slack_url=None):
if(not slack_url):
slack_url = "https://hooks.slack.com/services/.../.../..."
if(not payload_obj and message_text):
payload_obj = {"text":message_text,"link_names":1}
r = requests.put(slack_url,data=json.dumps(payload_obj))
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.