Spaces:
Sleeping
Sleeping
import requests | |
SLACK_BOT_TOKEN = os.getenv("SLACK_BOT_TOKEN") | |
SLACK_BOT_CHANNEL_ID = os.getenv("SLACK_BOT_CHANNEL_ID") | |
payload = {"channel": SLACK_BOT_CHANNEL_ID, "text": "This message was sent from Hugging Face demo workspace."} | |
headers = { | |
"Authorization": f"Bearer {SLACK_BOT_TOKEN}", | |
"Content-Type": "application/json", | |
} | |
response = requests.post( | |
"https://slack.com/api/chat.postMessage", json=payload, headers=headers | |
) | |
if response.status_code == 200 and response.json().get("ok"): | |
print("Message sent successfully!") | |
else: | |
print("Failed to send message:", response.json()) | |