Search code examples
slackslack-apislack-dialog

Uploading image via Slack interactive button


I have such interactive button I place at the bottom of backend-generated message:

enter image description here

The button click calls the dialog:

enter image description here

If I enter the public URL of an image in the 'URL' field it is successfully sent to the backend and I'm able to update the backend-generated message with an image. But instead of uploading file somewhere and copying it there I'd like to click 'upload image' in the dialog and select file from a disk. Is this possible?


Solution

  • No. Uploading files is currently not supported by Slack Dialogs.

    But you could implement it yourself with an upload script that runs in the browser and is called by a link button from Slack. This would work similar to this example for a file download.

    The link button is a variation of an message button and has to be placed in a message (e.g. next to your Add note button), but can not be placed inside the Dialog.

    Here is the basic outline:

    1. User clicks on "Add image" button in message
    2. Browse opens and runs upload script
    3. The upload script requests the user to specify which file to upload
    4. Script uploads the file (e.g. to your server or Slack) and links it to the user's request

    Things to consider:

    • You have to link the current session with your script, e.g. by transferring an ID in the link (which might infer security concerns)
    • This upload function will not be modal like you dialog, so your app needs to be able to handle an asynchronous / parallel upload of files

    Check out these pages for more details on uploading files via browser: