Hi <@ULVA73B9P>. I want to set a Slack notificatio...
# ask-marvin
d
Hi @Marvin. I want to set a Slack notification that will notify me only if a flow's final state is Failed or Crashed or TimedOut etc. I set up retries and at the moment I get a notification if any of the tries fail. I only want to be notified if all the tries and retries result in a failure i.e. the flow could not succeed at all.
m
To set up a Slack notification in Prefect that notifies you only if a flow's final state is "Failed", "Crashed", or "TimedOut" after all retries, you can utilize Prefect's automation and state change hooks functionality. Here's a general guide for both Prefect 2.x and 3.x versions with relevant documentation links. 1. Set Up Notifications: - In Prefect, you can configure notifications for specific flow states using the Automations interface. You can specify which states should trigger a notification, such as "Failed", "Crashed", or "TimedOut". - For Slack notifications, you'll need to provide the webhook URL and specify the Slack channel. 2. Automations and State Change Hooks: - Use state change hooks to execute code when a flow or task reaches a specific state. This could be combined with a condition to ensure notifications are only sent for specific states like “Failed” after all retries. - In Prefect 3.x, the Automations API allows you to define more granular conditions for when to trigger notifications. Links to help you set this up: - Prefect 2.x Notifications Guide: This guide provides details on setting up Slack or other notifications in Prefect. - Prefect 3.x Automations and Notifications: Learn about setting up notifications based on flow run states using Prefect 3.x features. By properly configuring these automation triggers, you can ensure you'll only be notified for the entire flow failure after all retries have been exhausted. Remember, though, to keep an eye on those webhook URLs, wouldn't want them to feel neglected, right? If you need further assistance or a sample code snippet to achieve this, let me know! Your flows' success is just a notification away.