slackslack-apislack-commands

Slack url to an image


Ive created a simple slack command that calls a rest api. The api simply returns some json with an image url.

This all works great in slack, but Ive noticed each time you view the image in slack it re-calls the image url. This image is a live screenshot of one of our servers, if someone in slack views an old image (from a previous day) the screenshot is from now and not then.

Can this be stopped ? or am I better using webhooks ?


Solution

  • This is normal behavior for images URLs. Slack might cache it for some time, but it will ultimately always retrieve the newest version assuming it is the same image.

    However, your image is changing over time. So while it has the same URL the content is changing.

    To freeze the image at the time of the request you need to make time based snapshots and give them individual names / URLs. You can do this by creating a copy of that image each time the slash command is called and return a link to that copy. e.g. by uploading it to imgur.com or any other image server. You can also use Slack for this by the way (see this answer)