prefect icon indicating copy to clipboard operation
prefect copied to clipboard

Formatting of teams web hook is broken

Open tharwan opened this issue 1 year ago • 3 comments

Bug summary

When configuring a teams web hook block using the new workflow based method from microsoft and creating an automation to notify on certain events, the notification does not get formatted properly. It looses all line breaks and contains no links.

Since the notification text is automatically wrapped in an "adaptive card" it appears no to be possible to create properly formatted notifications as has been the case previously using the (now outdated) web hooks from teams directly.

See also: https://github.com/PrefectHQ/prefect/issues/14575

Version info

prefect cloud

Additional context

No response

tharwan avatar Dec 09 '24 14:12 tharwan

I found a workaround that is good enough for our use case. The text that the automation sends will be interpreted as markdown in teams. Therefore links and line breaks can be created according to markdown syntax. This solves the most essential problems. E.g.

subject {{ flow.name }} run notification

and body:

Flow run {{ flow.name }}/{{ flow_run.name }} observed in state `{{ flow_run.state.name }}` at {{ flow_run.state.timestamp }}.

[{{ deployment.name }}]({{ deployment|ui_url }}) / [{{ flow_run.name }}]({{ flow_run|ui_url }})

State message: {{ flow_run.state.message }} 

result in an workable message in teams.

tharwan avatar Dec 17 '24 16:12 tharwan

One more thing: there is no support for things like block quotes in the markdown block of adaptive cards: https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cdesktop1%2Cdesktop2%2Cconnector-html#format-cards-with-markdown

so the current default for wrapping the state of a flow in a markdown block does not work, at least in terms of formatting.

tharwan avatar Jan 02 '25 14:01 tharwan

One problem with the missing ability to control the format of the adaptive card is also apparent when displaying the notifications on a mobile device with a small screen, where the default of teams is apparently to clip text instead of wrapping it.

tharwan avatar Jan 16 '25 13:01 tharwan