https://prefect.io logo
Title
b

Billy McMonagle

01/04/2023, 6:49 PM
Hi there, I wanted to check my understanding of feature availability in Prefect Cloud 2.0. Is it possible to send, for specific flow state changes, custom Slack notifications? Ideally using the Slack block kit rather than plain text. Thanks!
1
k

Kalise Richmond

01/04/2023, 7:04 PM
Hi @Billy McMonagle yes you can use the Slack block kit to create custom messages to send to slack by using the prefect-slack integration directly in your flow code.
b

Billy McMonagle

01/04/2023, 7:06 PM
oh cool, thanks! I was looking in the notifications section, not the integrations section. I assume I could just put something like
if task_result_state == FAIL: send_notification()
in my flow?
k

Kalise Richmond

01/04/2023, 7:08 PM
yes exactly, so you could use either the
send_chat_message()
or the
send_incoming_webhook_message()
from the integration directly in your flow code
b

Billy McMonagle

01/04/2023, 7:09 PM
perfect. Changing my 1.0 code is hard but this is much more intuitive and will let me delete some old code, hooray 🙂
:marvin: 3
a

Andrew Huang

01/04/2023, 8:01 PM
There’s also prefect-alert integration as a decorator
🙌 1
k

Kalise Richmond

01/04/2023, 9:58 PM
Oh yes!! you could use the
@alert_on_failure
decorator with the
prefect-slack
integration https://khuyentran1401.github.io/prefect-alert/