2

I'm trying to use a Slack webhook to notify a channel about a csv file for that day as well as post a link to it to attach. https://api.slack.com/docs/message-attachments doesn't use any examples of actual attachments and only includes links. I'm wondering if its even possible to send a csv file that my code is generating and attaching it from its path via os.path.basename(csvfile)

I'm trying use the format thats demonstrated here: https://gist.github.com/devStepsize/b1b795309a217d24566dcc0ad136f784 but am not sure if this allows for actual file attachments. So, I'd appreciate any help/direction in this matter. Is it even possible to send file attachments via a Slack webhook and if so, how should one go about doing so?

Keyadun
  • 715
  • 1
  • 7
  • 15
  • Possible duplicate of [Is it possible to post files to Slack using the incoming Webhook?](https://stackoverflow.com/questions/35742775/is-it-possible-to-post-files-to-slack-using-the-incoming-webhook) – Keyadun Oct 10 '18 at 20:40

1 Answers1

8

No, you can not attach a file via webhook. You can only include media links for specific formats that will then automatically be unfurled, e.g. images or videos.

To send a file into a channel you need to upload and share it in the channel via Slack API. The API method files.upload has that exact purpose. Make sure to include the channel ID in the channels property to enable the optional sharing function.

Note that for using the Slack Web API you will need a token.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114