https://prefect.io logo
a

Arnav Gupta

08/23/2023, 6:57 PM
Hi team, I am fairly new to Prefect. Couple of weeks back, we were experimenting with Teams block (notifications). Our use case is to send notifications summarizing all the statuses of different tasks. What I need help is on the following: • I want to keep the Teams channels limited, that is 1 teams channel to communicate status of multiple flows. And Teams notifications creates a new conversation for each notification. How can we create the subject for this conversation so that it clearly highlights details about what job/flow it is about? • Plus, some color coding on statuses would definitely segregate success vs failures Please help me point to right resources. Thanks!
Basically, looking to enhance the below message:
Hi team request you to please help with this. If it is already covered, kindly point me in that direction. Thanks!
Sorry tagging you out of the blue @Jake Kaplan , but would you be able to please guide me here?
j

Jake Kaplan

08/30/2023, 9:13 PM
Hi are you using Automations with Cloud or are you using notifications in the self hosted version?
a

Arnav Gupta

09/05/2023, 10:18 AM
Hi Jake Sorry for late response! I am using the blocks for notification on prefect cloud v2. Does that help?
@Jake Kaplan Tagging you for my response.
j

Jake Kaplan

09/07/2023, 3:40 PM
Hi apologies, I don't always get the notifications. You should be able to set the subject on the notification automation with templated values
additionally you if you two different automations for success/failure states, you can configure the notify type on the block itself
Screenshot 2023-09-07 at 11.41.27 AM.png
i'm not quite as familiar with teams, but at least for slack that corresponds to a color
a

Arnav Gupta

09/07/2023, 6:39 PM
@Jake Kaplan Thank you! I see! Can this happen without automation? when we are using a block? Because we are going to pass custom messages.
j

Jake Kaplan

09/07/2023, 6:43 PM
If you want to use the blocks directly inside of your code I think you can set the notify type on the block and then the subject in the notify method
Copy code
# things worked
block = MicrosoftTeamsWebhook(notify_type="success")
block.notify(body="", subject="something worked")

block = MicrosoftTeamsWebhook(notify_type="failure")
block.notify(body="", subject="something failed")
if you want to tie it directly to the success/failure state of your flow run, automations is a great way to do it, but if you need it to be in code you can use: https://docs.prefect.io/latest/guides/state-change-hooks/?h=state+hooks#state-change-hooks
and put your notification logic inside of the
on_completion
,
on_failure
hooks
a

Arnav Gupta

09/11/2023, 10:11 AM
Thank you so much @Jake Kaplan!!