skillfed

slackblocks

Python wrapper for the Slack Blocks API

slackblocks v2.1.0 78.5K downloads/30d#14,436 on PyPI75
Permissive license MIT Active released

What it is and what it does

slackblocks is a typed Python wrapper around Slack's Block Kit API that lets you construct rich Slack messages, modals, and home tabs using concise Python objects instead of verbose JSON. It enforces validation at construction time—character limits, required fields, mutually-exclusive options, element-type restrictions—so errors surface before the API call, not after. The library ships with full type hints and zero runtime dependencies, making it lightweight and IDE-friendly.

It integrates directly with official Slack SDKs via unpacking: `client.chat_postMessage(**message)` works without boilerplate. The package supports all current block types (including Alert, Card, Carousel, Container, Data Table, Plan, Task Card), elements (buttons, select menus, date/time pickers, checkboxes, radio groups, workflow buttons), composition objects, rich text, modals, views, and round-trip parsing of incoming Slack JSON back into objects.

Use it for:

  • Build structured build-status notifications with fields, buttons, and dividers without writing JSON templates.
  • Generate approval-request modals with validation and interactive elements for workflow automation.
  • Construct data-driven Slack messages (e.g., incident alerts, report summaries) with type-safe field assembly.
  • Parse incoming Slack interaction payloads back into slackblocks objects for programmatic inspection and response.
  • Create reusable message templates as Python functions, leveraging type hints for IDE autocomplete and refactoring.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Builds Slack Block Kit messages programmatically in Python with type validation, eliminating hand-written JSON and reducing API errors before they reach Slack.

Yes. Zero dependencies, active maintenance, permissive dual licensing, and no known vulnerabilities make it a safe choice. Install if you send structured Slack messages from Python and want to avoid JSON boilerplate and validation errors—the typed API and up-front validation pay off immediately. Requires Python 3.10 or newer.

Install

slackblocks on PyPI

pip

pip install slackblocks

uv

uv add slackblocks

poetry

poetry add slackblocks

Installing slackblocks

Before you install

Installs with zero runtime dependencies as a pure-Python wheel. Active maintenance with a release on 2026-08-14 and 75 repository stars.

License in practice

Dual-licensed under MIT and BSD-3-Clause, permitting use in both permissive and copyleft projects; choose whichever fits your licensing requirements.

Quickstart

pip install slackblocks

from slackblocks import Message, HeaderBlock, SectionBlock, Button, ActionsBlock

message = Message(
    channel="#general",
    text="Build passed",
    blocks=[
        HeaderBlock("Build #482 passed :white_check_mark:"),
        SectionBlock(fields=["*Branch*\n`main`", "*Author*\n@nick"]),
        ActionsBlock(elements=[Button(text="View", url="https://example.com")])
    ]
)

Requires Python 3.10 or newer; Python 3.8/3.9 users must pin to the 1.x line.

Verify before relying

  • Whether the package's round-trip parsing (Block.from_dict) handles all current Slack API responses without data loss.
  • Performance characteristics when building large messages with hundreds of blocks or elements.
  • Compatibility with Slack API changes after the 2026-08-14 release date.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 0 days since the last release
Last repo commit
First released
Downloads 78,520/month — #14,436 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: slackblocks-2.1.0-py3-none-any.whl

Keywords: blocks, message generation, messaging, slack, slack blocks, slackblocks

License :: OSI Approved :: BSD LicenseLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Communications :: ChatTyping :: Typed

Tags

slack message builder pythonblock kit wrapperslack blocks apityped slack messagesslack json generatorslack message validationslack message construction
slack-integrationmessage-generationtype-safe

More Chat packages