1

I am creating a Slack Bot which will grab all the metrics from data sources and post to Slack regularly in a channel.

I've managed to post to Slack regularly with the data I would like to show with a Webhook, however I also would like to post an image of a line chart for the metrics I want to include. When adding an examplary public url to the Block Kit JSON file, I am able to send the message. However when I try to post the image (basically changing "image_url" with what Slack gives me as a public/private url) that I've just uploaded to Slack, leads to the below error:

ValueError: Request to slack returned an error 400, the response is: invalid_blocks

I've tried all the url's Slack provided including: url_private, url_private_download, permalink, permalink_public with no success. I also used files.SharedPublicURL and converted the url to a public one, still having the same error message.

Block Kit JSON

{
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "plain_text",
                "text": "Here's an image I'd like to post!",
                "emoji": true
            }
        },
        {
            "type": "image",
            "title": {
                "type": "plain_text",
                "text": "TestImage",
                "emoji": true
            },
            "image_url": "https://www.researchgate.net/profile/Hongtao_Yi/publication/308085943/figure/fig1/AS:420741989322752@1477324115445/Time-trend-of-target-completion.png",
            "alt_text": "TestImage"
        }
    ]
}

I've tried different methods such as is in here but still getting the same error.

burakito
  • 23
  • 5

0 Answers0