-
Notifications
You must be signed in to change notification settings - Fork 16
Implementation Snippets
Thomas Howe edited this page Mar 24, 2023
·
3 revisions
import requests
import datetime
def publish_to_slack(url, summary, link, call_at, duration):
start = datetime.datetime.fromisoformat(call_at)
slack_messsage = {
"text": summary,
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": f"*{start.strftime('%b %d %Y %H:%M:%S')}*: {duration} seconds. <{link}|Details>"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": summary
}
}
]
}
response = requests.post(url, json=slack_messsage)