Discord Alerter
Sending automated alerts to a Discord channel.
Last updated
Was this helpful?
Sending automated alerts to a Discord channel.
Last updated
Was this helpful?
The DiscordAlerter
enables you to send messages to a dedicated Discord channel directly from within your ZenML pipelines.
The discord
integration contains the following two standard steps:
takes a string message, posts it to a Discord channel, and returns whether the operation was successful.
also posts a message to a Discord channel, but waits for user feedback, and only returns True
if a user explicitly approved the operation from within Discord (e.g., by sending "approve" / "reject" to the bot in response).
Interacting with Discord from within your pipelines can be very useful in practice:
The discord_alerter_post_step
allows you to get notified immediately when failures happen (e.g., model performance degradation, data drift, ...),
The discord_alerter_ask_step
allows you to integrate a human-in-the-loop into your pipelines before executing critical steps, such as deploying new models.
Before you can use the DiscordAlerter
, you first need to install ZenML's discord
integration:
In order to use the DiscordAlerter
, you first need to have a Discord workspace set up with a channel that you want your pipelines to post to. This is the <DISCORD_CHANNEL_ID>
you will need when registering the discord alerter component.
Then, you need to .
Next, you need to register a discord
alerter in ZenML and link it to the bot you just created. You can do this with the following command:
After you have registered the discord_alerter
, you can add it to your stack like this:
Here is where you can find the required parameters:
Open the discord server, then right-click on the text channel and click on the 'Copy Channel ID' option.
When inviting the bot to your channel, make sure it has at least the following permissions:
Read Messages/View Channels
Send Messages
Send Messages in Threads
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 discord_alerter_ask_step()
to your pipeline could look like this:
This is the Discord token of your bot. You can find the instructions on how to set up a bot, invite it to your channel, and find its token.
After you have a DiscordAlerter
configured in your stack, you can directly import the and steps and use them in your pipelines.
For more information and a full list of configurable attributes of the Discord alerter, check out the .