os / slacker

Full-featured Python interface for the Slack API
Apache License 2.0
1.6k stars 245 forks source link

Can't send messages with blocks #163

Open hiroki-tagami opened 4 years ago

hiroki-tagami commented 4 years ago

This code results in an error.

from slacker import Slacker

slack = Slacker("token")

blocks = [
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": "Start <https://google.com|Show> | <https://google.com|Cancel>"
                }
            },
        ]

slack.chat.post_message('#channnel-name', blocks=blocks)

Upon investigation, the block is not json-encoded.

Is it OK to send the modified PR?

Martian-II commented 4 years ago

Hi The block must be JSON data. Try blocks = json.dumps(blocks) .