> \

--default_slack_channel_id=<SLACK_CHANNEL_ID>Here is where you can find the required parameters:

<SLACK_CHANNEL_ID>: Open your desired Slack channel in a browser, and copy out the last part of the URL starting with C.....

<SLACK_TOKEN>: This is the Slack token of your bot. You can find it in the Slack app settings under OAuth & Permissions. IMPORTANT: Please make sure that the token is the Bot User OAuth Token not the User OAuth Token.

After you have registered the slack_alerter, you can add it to your stack like this:

zenml stack register ... -al slack_alerter

How to Use the Slack Alerter

After you have a SlackAlerter configured in your stack, you can directly import the slack_alerter_post_step and slack_alerter_ask_step steps and use them in your pipelines.

Since these steps expect a string message as input (which needs to be the output of another step), you typically also need to define a dedicated formatter step that takes whatever data you want to communicate and generates the string message that the alerter should post.

As an example, adding slack_alerter_ask_step() to your pipeline could look like this:

from zenml.integrations.slack.steps.slack_alerter_ask_step import slack_alerter_ask_step

from zenml import step, pipeline

@step

def my_formatter_step(artifact_to_be_communicated) -> str:

return f"Here is my artifact {artifact_to_be_communicated}!"

@pipeline

def my_pipeline(...):

...

artifact_to_be_communicated = ...

message = my_formatter_step(artifact_to_be_communicated)

approved = slack_alerter_ask_step(message)

... # Potentially have different behavior in subsequent steps if `approved`

if __name__ == "__main__":

my_pipeline()

An example of adding a custom Slack block as part of any alerter logic for your pipeline could look like this:

from typing import List, Dict

from zenml.integrations.slack.steps.slack_alerter_ask_step import slack_alerter_post_step

from zenml.integrations.slack.alerters.slack_alerter import SlackAlerterParameters

from zenml import step, pipeline

@step