{"id":7048,"library":"blockkit","title":"Blockkit","description":"Blockkit is a Python library for building user interfaces for Slack apps. It provides a fluent API with type hints and validation, allowing developers to compose Slack's Block Kit elements using Python classes, which reduces boilerplate and improves maintainability. The library is currently at version 2.1.3 and is actively maintained with frequent releases.","status":"active","version":"2.1.3","language":"en","source_language":"en","source_url":"https://github.com/imryche/blockkit","tags":["slack","block kit","ui builder","messaging"],"install":[{"cmd":"pip install blockkit","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"Modal","correct":"from blockkit import Modal"},{"symbol":"Section","correct":"from blockkit import Section"},{"symbol":"Message","correct":"from blockkit import Message"},{"symbol":"Button","correct":"from blockkit import Button"},{"symbol":"Confirm","correct":"from blockkit import Confirm"}],"quickstart":{"code":"from blockkit import Message, Section, Button, Confirm\n\nmessage = (\n    Message()\n    .add_block(Section(\"Please approve *Alice's* expense report for $42\")) # Markdown detected automatically\n    .accessory(\n        Button(\"Approve\")\n        .action_id(\"approve_button\")\n        .style(Button.PRIMARY)\n        .confirm(\n            Confirm()\n            .title(\"Are you sure?\")\n            .text(\"This action cannot be undone\")\n            .confirm(\"Yes, approve\")\n            .deny(\"Cancel\")\n        )\n    )\n    .thread_ts(os.environ.get('SLACK_THREAD_TS', '1234567890')) # Converts types automatically\n    .build() # Validates everything: types, lengths, required fields\n)\n\n# To send this message via Slack's WebClient, you would typically do:\n# from slack_sdk import WebClient\n# client = WebClient(token=os.environ.get(\"SLACK_BOT_TOKEN\"))\n# response = client.chat_postMessage(\n#     channel=\"C12345\",\n#     blocks=message # Blockkit objects are directly serializable to JSON dicts expected by Slack SDK\n# )\n\nprint(message)","lang":"python","description":"This example constructs a Slack message with an approval request, including a button with a confirmation dialog. The `.build()` method validates the Block Kit structure, ensuring compliance with Slack's API specifications. The generated `message` object can be directly passed to the `blocks` parameter of `slack_sdk.WebClient.chat_postMessage`."},"warnings":[{"fix":"Rewrite Block Kit UI construction using the new fluent API. Refer to the official documentation for migration guidance and new syntax.","message":"Version 2.0.0 was a complete rewrite of the library with a new fluent API and zero dependencies. Code written for versions prior to 2.0.0 will not be compatible.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Configure the 'Request URL' in your Slack App settings (api.slack.com/apps) under 'Interactivity & Shortcuts'. Ensure your server endpoint correctly receives and processes Slack's `POST` requests.","message":"When using interactive components (e.g., buttons, select menus) within Blockkit, ensure your Slack App's 'Interactivity & Shortcuts' feature has a properly configured 'Request URL'. Without this, Slack cannot send interaction payloads (like `block_action`) to your application.","severity":"gotcha","affected_versions":"All"},{"fix":"Refer to Slack's 'Formatting text for app surfaces' documentation for exact 'mrkdwn' syntax. Blockkit's automatic detection usually works, but manual review for complex formatting may be needed.","message":"Slack's 'mrkdwn' formatting has subtle differences from standard Markdown. While Blockkit aims to handle common cases automatically, be aware of specific syntax requirements for elements like links (`<url|text>`) or bold (`*text*`).","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure all Blockkit components are correctly instantiated and chained according to the library's fluent API. The `.build()` method performs validation; check its output for detailed errors. Use Block Kit Builder (api.slack.com/tools/block-kit-builder) to prototype and validate your structure.","cause":"The generated Block Kit JSON structure is malformed or does not adhere to Slack's API specifications (e.g., missing required fields, incorrect types, invalid nesting).","error":"slack.errors.SlackApiError: The request to Slack API Failed. The server responded with: {'ok': False, 'error': 'invalid_blocks_format'}"},{"fix":"Verify that your Slack App's 'Interactivity & Shortcuts' 'Request URL' is correctly set and your server is publicly accessible. Also, ensure interactive elements in your Blockkit structure are properly nested within `Actions` blocks or `Input` blocks configured to dispatch actions.","cause":"The interactive elements (e.g., buttons) are not correctly configured within an `ActionsBlock` or `InputBlock` with `dispatch_action: true`, or the Slack App's 'Request URL' for interactivity is not set up or reachable.","error":"Not receiving block_action payload when interacting with a Slack Block Kit modal/message"}]}