Quick Start
Install slackblocks and build your first valid Block Kit message. The language selector in the top navigation controls the instructions and examples on this page.
Install the package
Python 3.10 or newer is required.
pip install slackblocks
Build a message
from slackblocks import Message, SectionBlock
message = Message(
channel="#general",
text="Hello from slackblocks!",
blocks=[SectionBlock("Hello, world!")],
)
print(message.json())
Message validates the payload as it is constructed and renders it as Slack-compatible JSON. The text value is the plain-text fallback Slack uses for notifications and accessibility.
Install the package
Node.js 20.19 or newer is required. The package is ESM-only.
pnpm add @nicklambourne/slackblocks
Build a message
import { Message, SectionBlock } from "@nicklambourne/slackblocks";
const payload = Message()
.channel("C0123456")
.text("Hello from slackblocks!")
.blocks(SectionBlock().text("Hello, world!"))
.build();
console.log(JSON.stringify(payload, null, 2));
Each builder uses typed camelCase setters. .build() validates the completed
payload and returns the plain snake_case object expected by Slack.
Install the module
Go 1.22 or newer is required.
mkdir slackblocks-hello
cd slackblocks-hello
go mod init example.com/slackblocks-hello
go get github.com/nicklambourne/slackblocks/go/v2
Build a message
package main
import (
"context"
"os"
slackblocks "github.com/nicklambourne/slackblocks/go/v2"
slack "github.com/slack-go/slack"
)
func main() {
client := slack.New(os.Getenv("SLACK_API_TOKEN"))
_, _, err := client.PostMessageContext(
context.Background(),
os.Getenv("SLACK_CHANNEL_ID"),
slack.MsgOptionText("Hello from slackblocks!", false),
slack.MsgOptionBlocks(
slackblocks.NewSectionBlock().Text("Hello, world!"),
),
)
if err != nil {
panic(err)
}
}
The block builder implements slack.Block and validates when slack-go marshals it, before the request is sent. The channel and fallback text stay in slack-go, where its other message options can be added normally. Use NewMessage().Build() instead when you need a complete JSON-compatible Object for another client.
Where to go next
slackblocks constructs the Block Kit content while the established Slack client handles delivery. Continue with Sending Messages for more client options, or explore Using Blocks to build richer layouts.
For package-manager alternatives and environment details, see Installation.