slack send message python
import os
import slack
slack_token = os.environ["SLACK_API_TOKEN"]
client = slack.WebClient(token=slack_token)
client.chat_postMessage(
channel="C0XXXXXX",
text="Hello from your app! :tada:"
)
slack send message python
import os
import slack
slack_token = os.environ["SLACK_API_TOKEN"]
client = slack.WebClient(token=slack_token)
client.chat_postMessage(
channel="C0XXXXXX",
text="Hello from your app! :tada:"
)
pyhton code to send file to slack
def send_file_to_slack(file_path):
url = "https://slack.com/api/files.upload"
# this is where you add your query string. Please chage token value
querystring = {"token": xxxxxxx}
# this is where you define who do you want to send it to. Change channels to your target one
payload = {
"channels": xxxxxxxx, # slack channel id
"initial_comment": comment above the file should be here"
}
file_upload = {
"file": (file_path, open(file_path, 'rb'), 'csv')
}
response = requests.post(url, data=payload, params=querystring, files=file_upload)
if response.ok:
return {
"message": "Successfully uploaded the file to slack"
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us