ziv-conntour commited on
Commit
161ee78
·
verified ·
1 Parent(s): a9fc5f5

Update slack_bot.py

Browse files
Files changed (1) hide show
  1. slack_bot.py +15 -14
slack_bot.py CHANGED
@@ -1,20 +1,21 @@
1
  import requests
2
 
3
- SLACK_BOT_TOKEN = os.getenv("SLACK_BOT_TOKEN")
4
- SLACK_BOT_CHANNEL_ID = os.getenv("SLACK_BOT_CHANNEL_ID")
5
 
6
- payload = {"channel": SLACK_BOT_CHANNEL_ID, "text": "This message was sent from Hugging Face demo workspace."}
7
 
8
- headers = {
9
- "Authorization": f"Bearer {SLACK_BOT_TOKEN}",
10
- "Content-Type": "application/json",
11
- }
 
 
12
 
13
- response = requests.post(
14
- "https://slack.com/api/chat.postMessage", json=payload, headers=headers
15
- )
16
 
17
- if response.status_code == 200 and response.json().get("ok"):
18
- print("Message sent successfully!")
19
- else:
20
- print("Failed to send message:", response.json())
 
1
  import requests
2
 
3
+ SLACK_BOT_TOKEN = "xoxb-7956608570179-8288868683413-szG80H8DCFQvTbQSxMgN0z3S"
4
+ SLACK_BOT_CHANNEL_ID = "C088D2NLN5C"
5
 
 
6
 
7
+ def send_slack_message(message: str):
8
+ payload = {"channel": SLACK_BOT_CHANNEL_ID, "text": message}
9
+ headers = {
10
+ "Authorization": f"Bearer {SLACK_BOT_TOKEN}",
11
+ "Content-Type": "application/json",
12
+ }
13
 
14
+ response = requests.post(
15
+ "https://slack.com/api/chat.postMessage", json=payload, headers=headers
16
+ )
17
 
18
+ if response.status_code == 200 and response.json().get("ok"):
19
+ print("Message sent successfully!")
20
+ else:
21
+ print("Failed to send message:", response.json())