Installation
Choose Python, TypeScript, or Go from the site navigation. The selection applies across the documentation and is preserved as you move between pages.
Install the Python package from PyPI:
- pip
- Poetry
- Pipenv
- uv
pip install slackblocks
poetry add slackblocks
pipenv install slackblocks
uv add slackblocks
Python 2.x requires Python 3.10 or newer and has no runtime dependencies. See Compatibility for the support matrix and 1.x migration guidance.
Verify the installation:
from slackblocks import Message, SectionBlock
print(Message(channel="#general", blocks=SectionBlock("Hello, world!")).json())
Pin the current major release with slackblocks~=2.0, and uninstall with pip uninstall slackblocks (or the equivalent command for your package manager).
Install the ESM package from npm:
- pnpm
- npm
- Yarn
pnpm add @nicklambourne/slackblocks
npm install @nicklambourne/slackblocks
yarn add @nicklambourne/slackblocks
The package requires Node 20.19 or newer, is ESM-only, and emits no runtime imports beyond your own code.
Verify the installation in hello.mjs:
import { Message, SectionBlock } from "@nicklambourne/slackblocks";
console.log(
Message()
.channel("C0123456")
.blocks(SectionBlock().text("Hello, world!"))
.build(),
);
Run it with node hello.mjs. Stay on the 2.x release line with @nicklambourne/slackblocks@^2.1.0, and uninstall with pnpm remove @nicklambourne/slackblocks (or your package manager's equivalent).
From an existing Go module, install the v2 Go module directly from GitHub:
go get github.com/nicklambourne/slackblocks/go/v2
Go 1.22 or newer is required. Block builders implement slack.Block directly using the Go 1.22-compatible github.com/slack-go/slack release; go get installs that dependency automatically.
Verify the installation in main.go:
package main
import (
"fmt"
slackblocks "github.com/nicklambourne/slackblocks/go/v2"
)
func main() {
payload, err := slackblocks.NewMessage().
Channel("C0123456").
Blocks(slackblocks.NewSectionBlock().Text("Hello, world!")).
Build()
if err != nil {
panic(err)
}
fmt.Println(payload)
}
Run it with go run .. The /v2 suffix is part of the module path under Go's semantic import versioning; update within the current major line with go get -u github.com/nicklambourne/slackblocks/go/v2.