Skip to main content

blockkit-logo

Build status PyPI version Downloads


Documentation: https://blockkit.botsignals.co

Source Code: https://github.com/imryche/blockkit


BlockKit for Python

Build beautiful Slack UIs fast. Fluent API with type hints, validation, and zero dependencies.

pip install blockkit

Here's the thing

Building Slack apps shouldn't feel like writing JSON by hand. It's tedious. It's error prone. And honestly? It's a waste of your time.

You know what you want to build. Your editor should help you build it. That's what BlockKit for Python does.

Before

This is what you're probably doing now:

# Building a simple approval message. What could go wrong?
message = {
    "blocks": [{
        "type": "section",
        "text": {
            "type": "mrkdwn",  # 🤔 or was it "markdown"?
            "text": "Please approve *Alice's* expense report for $42"
        },
        "accessory": {
            "type": "button",
            "text": {
                "type": "plain_text",  # 😕 wait, why can't buttons use mrkdwn?
                "text": "Approve"      # 🤞 hope this isn't too long
            },
            "action_id": "approve_button",
            "style": "green",  # ❌ is it "green"? "success"? "primary"?
            "confirm": {       # 🤔 what's the structure again?
                "title": {
                    "type": "plain_text",
                    "text": "Are you sure?"
                },
                "text": {
                    "type": "plain_text",
                    "text": "This action cannot be undone"
                },
                "confirm": {
                    "type": "plain_text",
                    "text": "Yes, approve"
                }
                # ❌ forgot the required "deny" field
            }
        }
    }],
    "thread_ts": 1234567890  # ❌ wait, should this be a string?
}

# Three bugs. Deeply nested JSON. Good luck debugging this.

Nest some JSON. Guess field names. Cross your fingers. Test it. Get an error. Try again. Sound familiar?

After

Here's the same thing:

from blockkit import Message, Section, Button, Confirm

message = (
    Message()
    .add_block(
        Section("Please approve *Alice's* expense report for $42")  # ✅ Markdown detected automatically
        .accessory(
            Button("Approve")
            .action_id("approve_button")
            .style(Button.PRIMARY)  # ✅ Class constants prevent typos
            .confirm(
                Confirm()
                .title("Are you sure?")
                .text("This action cannot be undone")
                .confirm("Yes, approve")
                .deny("Cancel")  # ✅ Can't forget required fields
            )
        )
    )
    .thread_ts(1234567890)  # ✅ Converts types automatically
    .build()  # ✅ Validates everything: types, lengths, required fields
)

# Clean. Readable. BlockKit catches errors before you event send it to Slack.

Done. No guessing. No runtime surprises. Your editor helped you write it.

The difference

The library knows Slack's rules, so you don't have to memorize them. Your editor autocompletes everything. Validation happens immediately.

When something's wrong, you'll know right away - not after deploying.

Real example

Let's build something real. An approval flow:

from blockkit import Modal, Section, Input, PlainTextInput, RadioButtons, Option

modal = (
    Modal()
    .title("Expense Approval")
    .add_block(Section("*New expense request from Alice*"))
    .add_block(
        Input("Amount").element(
            PlainTextInput().initial_value("$42.00").action_id("amount")
        )
    )
    .add_block(
        Input("Decision").element(
            RadioButtons()
            .add_option(Option("Approve ✅", "approve"))
            .add_option(Option("Reject ❌", "reject"))
            .action_id("decision")
        )
    )
    .submit("Submit")
    .build()
)

That's it. Clear, readable, and it works the first time.

Why we built this

We got tired of:

  • Reading Slack's docs for the 100th time
  • Building UIs that are impossible to refactor
  • Shipping "perfect" JSON that Slack rejects for mysterious reasons

So we fixed it. One library. No dependencies. Just better.

Want more?

Check out blockkit.botsignals.co for the full docs. Or don't. The code is pretty self-explanatory.


Made by Botsignals

Release files for blockkit 2.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blockkit 2.1.3
File Size Uploaded
blockkit-2.1.3.tar.gz 67.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for blockkit 2.1.3
File Interpreter ABI Platform
blockkit-2.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 87.2 kB

Release files / blockkit-2.1.3.tar.gz

Download URL blockkit-2.1.3.tar.gz
Size 67.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f71de30029afdce3e7cd3d869519c7207788e419267898acd6445d471b112215
BLAKE2b-256 checksum
How to use checksums
3d9bef26b291946a79bd295d0d7a70ca8e109e0a7b4ea13620da969101d71f38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / blockkit-2.1.3-py3-none-any.whl

Download URL blockkit-2.1.3-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d92c30296770de6a8a4f0ac30fa6f6c78881c45a22d808bdb33767cfa0ea7bb9
BLAKE2b-256 checksum
How to use checksums
30ae5fcb4710c070bf2d51a4f90baf58105b211499f09c311b93b840dc5a0c06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

2.1.3 This release

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.4

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page