xtr-slack-notifier
Slack for xtr-notifier — chat messages posted, scheduled and updated in a channel, with Block Kit blocks, configured by DSN.
Why?
xtr-notifier sends chat messages through whatever provider a DSN names. This
library is the Slack provider: installed beside it, a slack:// DSN is served with no wiring, a
notification is rendered as Block Kit sections, and a message can be laid out with blocks,
scheduled for later, or updated once posted.
Install
uv add xtr-slack-notifier
It needs an HTTP client implementing xtr-http-client-contracts — usually xtr-http-client.
Quick start
from xtr_http_client import HttpClient
from xtr_notifier import Chatter, Transport
from xtr_notifier.message import ChatMessage
from xtr_notifier.transport import TransportFactoryDiscovery
discovery = TransportFactoryDiscovery(
TransportFactoryDiscovery.CHATTER_GROUP, http_client=HttpClient.create()
)
transport = Transport(discovery=discovery).from_string("slack://xoxb-1234@default?channel=ops")
sent = await Chatter(transport).send(ChatMessage("Deploy finished."))
The DSN
slack://TOKEN@default?channel=CHANNEL
TOKEN— a bot (xoxb-), user (xoxp-) or app (xoxa-2) token; a DSN without one is refused withUser is not set., and a token of another kind withA valid Slack token needs to start with "xoxb-", "xoxp-" or "xoxa-2". ...when the transport is built — on first use, since the notifier builds its transports lazily.default—slack.com; name another host (and port) for a test server.channel— the channel a message naming none is posted to.ssl=false— reach the host over plain HTTP.
The transport's string form — what errors, events and debug:config show — is
slack://slack.com?channel=CHANNEL: never the token. The token is sent as a bearer credential.
Options and blocks
SlackOptions builds what a message carries beyond its text; to_options() renders it for the
message:
from xtr_notifier.message import ChatMessage
from xtr_slack_notifier import SlackOptions
from xtr_slack_notifier.block import SlackActionsBlock, SlackHeaderBlock, SlackSectionBlock
options = (
SlackOptions()
.recipient("C0123456789")
.block(SlackHeaderBlock("Deploy 42"))
.block(SlackSectionBlock().text("*Finished* in 42s.").field("*Env*").field("production"))
.block(SlackActionsBlock().button("Open", "https://example.com/deploys/42", "primary"))
)
await chatter.send(ChatMessage("Deploy 42 finished.", options.to_options()))
The setters are recipient, as_user, icon_emoji, icon_url, link_names, mrkdwn, parse,
unfurl_links, unfurl_media, username, thread_ts (reply in a thread), post_at (schedule
through chat.scheduleMessage) and block. A message takes up to 50 blocks.
The blocks, under xtr_slack_notifier.block: SlackSectionBlock (text, up to 10 fields, an
accessory), SlackHeaderBlock, SlackContextBlock (up to 10 texts and images),
SlackActionsBlock (up to 25 buttons), SlackDividerBlock, SlackImageBlock and
SlackPlainTextInputBlock; the elements SlackButtonBlockElement and SlackImageBlockElement.
Anything else implements SlackBlockInterface.
A message made from a notification and carrying no options is rendered with
SlackOptions.from_notification(summary): the emoji as the icon, a section for the subject, one
for the content, and the exception's traceback after a divider.
Fields left empty — None, "", an empty list or mapping — are not sent; False and 0 are.
Updating a message
The transport returns a SlackSentMessage, carrying the channel (channel_id) and the message's
ts (message_id). get_update_message(subject, options) makes the message replacing it, sent
through chat.update:
sent = await chatter.send(ChatMessage("Deploying..."))
await chatter.send(sent.get_update_message("Deployed."))
Its options are UpdateMessageSlackOptions(channel_id, ts, options), which render with the kind
slack.update — the transport accepts both kinds, and tells them apart by it after the message
crossed a message bus.
Errors
| Error | When |
|---|---|
IncompleteDsnError |
The DSN carries no token (User is not set.) |
InvalidArgumentError |
The token does not start with xoxb-, xoxp- or xoxa-2 |
UnsupportedSchemeError |
The factory was handed a DSN that is not slack:// |
UnsupportedMessageTypeError |
The transport was handed a message that is not a ChatMessage |
LogicError |
More than 50 blocks, 25 buttons, or 10 fields or context elements |
LengthError |
A header over 150 characters, an input label or placeholder over 150, an id over 255 |
TransportError |
Unable to post the Slack message: "<error>" (<errors>). when Slack answers ok: false, Unable to post the Slack message: "<body>". on another status, or Could not reach the remote Slack server. |
Every one of them is xtr-notifier's; TransportError is what failover moves on from.
Use in an application
Everything adding this package to an application takes — and, read backwards, what removing it undoes. It ships no bundle: the notifier's bundle finds its factory by the DSN scheme.
- Install —
uv add xtr-slack-notifier, besidextr-notifierset up as its Use in an application says. - Recipe —
uv run xtr-recipes recipes:syncdoes the Environment step below: it writesSLACK_DSNin.env. It prints the step adding the transport to<app>/config/packages/notifier.py, which a recipe cannot make for you. - Configure — add
slack=env("SLACK_DSN")tochatter_transportsin<app>/config/packages/notifier.py. - Environment —
SLACK_DSN,slack://TOKEN@default?channel=CHANNELwith the app's token and the channel; read when a message is first sent. - Remove — drop the
chatter_transportsentry andSLACK_DSN, thenuv remove xtr-slack-notifier. - Check —
debug:config notifierlistsslackunderchatter_transports.
Everything else — the bundle, the channel policy, queuing through the message bus — is xtr-notifier's.
Development
uv run pytest
uv run ruff check
uv run ruff format --check
uv run basedpyright
uv run ty check
License
MIT — see LICENSE.
Metadata
Release files for xtr-slack-notifier 6.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xtr_slack_notifier-6.0.0.tar.gz | 18.3 kB | With provenance | Details for xtr_slack_notifier-6.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xtr_slack_notifier-6.0.0-py3-none-any.whl | Python 3 | none | any | Details for xtr_slack_notifier-6.0.0-py3-none-any.whl |
Total release size: 45.9 kB
Release files / xtr_slack_notifier-6.0.0.tar.gz
| Download URL | xtr_slack_notifier-6.0.0.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c59e1b7b6d526cc2a40ae6185bf5e71a692f0ff2b34d932001ae95212f578cf4
|
|
BLAKE2b-256 checksum How to use checksums |
04b20d6560183f85544b93de097a3eddd815edc5d49dd9e915a828214e55ddec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logRelease files / xtr_slack_notifier-6.0.0-py3-none-any.whl
| Download URL | xtr_slack_notifier-6.0.0-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
651acca7915e4fe2656e7f8a2691c7b05b3ba181716dcae763b0cb6521f40142
|
|
BLAKE2b-256 checksum How to use checksums |
b78f1156dc70895da49a645afcc7051d0ad7f2d4f7569e9bdd7c776d64f40cfb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logSecurity for xtr-slack-notifier 6.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for xtr_slack_notifier-6.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.