Here is my code to send a pdf file to my slack workspace. But it produces error.
client = WebClient(token=os.environ[SLACK_BOT_TOKEN])
try:
filepath = "./output.pdf"
response = client.files_upload(channels='#mychannelid_here', file=filepath)
assert response["file"] # the uploaded file
except SlackApiError as e:
# You will get a SlackApiError if "ok" is False
assert e.response["ok"] is False
assert e.response["error"] # str like 'invalid_auth', 'channel_not_found'
print(f"Got an error: {e.response['error']}")
Error is :
raise KeyError(key) from None KeyError: SLACK_BOT_TOKEN_HERE
Thanks in advance for help !