Slack Alerter

Sending automated alerts to a Slack channel.

The SlackAlerter enables you to send messages to a dedicated Slack channel directly from within your ZenML pipelines.

The slack integration contains the following two standard steps:

slack_alerter_post_step takes a string message or a custom Slack block, posts it to a Slack channel, and returns whether the operation was successful.

slack_alerter_ask_step also posts a message or a custom Slack block to a Slack channel, but waits for user feedback, and only returns True if a user explicitly approved the operation from within Slack (e.g., by sending "approve" / "reject" to the bot in response).

Interacting with Slack from within your pipelines can be very useful in practice:

The slack_alerter_post_step allows you to get notified immediately when failures happen (e.g., model performance degradation, data drift, ...),

The slack_alerter_ask_step allows you to integrate a human-in-the-loop into your pipelines before executing critical steps, such as deploying new models.

How to use it

Requirements

Before you can use the SlackAlerter, you first need to install ZenML's slack integration:

zenml integration install slack -y

See the Integrations page for more details on ZenML integrations and how to install and use them.

Setting Up a Slack Bot

In order to use the SlackAlerter, you first need to have a Slack workspace set up with a channel that you want your pipelines to post to.

Then, you need to create a Slack App with a bot in your workspace.

Make sure to give your Slack bot chat:write and chat:write.public permissions in the OAuth & Permissions tab under Scopes.

Registering a Slack Alerter in ZenML

Next, you need to register a slack alerter in ZenML and link it to the bot you just created. You can do this with the following command:

zenml alerter register slack_alerter \

--flavor=slack \

--slack_token=<SLACK_TOKEN> \

--default_slack_channel_id=<SLACK_CHANNEL_ID>