I am using Slack's API for sending messages, using the blocks
parameter for formatted messages. Now, I want to add the feature of attaching files to the messages, just like you would via the Slack interface (e.g. copy pasting an image / uploading a pdf).
After exploring the API and searching online, I couldn't find a way to have both blocks
and files
in the same API call for sending a message:
blocks
but does not accept file Ids/urls.initial_comment
as a simple string text, but does not accept blocks
for rich text.blocks
- this seems to work, but marks the message in Slack as edited
- a non ideal user experience.Is there a way to get the full capabilities of 'files' and 'blocks' while sending a message in 1 API call to Slack?
It seems to me it should be possible, since the other direction works - when Slack send an event of a new message in their events, they do share both blocks
and files
in the same event.
From Slack support:
For messages posted via the Slack API, we currently only support attaching image files via the slack_file or image block. Alternatively, you could try using remote files to see if that works for you - https://api.slack.com/messaging/files#remote
If remote files doesn't work, your best bet is option 4 to be honest. Sorry for the bad news here.