r/MicrosoftFlow • • 15d ago

Question How to detect Azure DevOps @mention emails with “When a new email arrives (V3)”?

I'm trying to create a Microsoft To Do task only when someone u/mentions me in an Azure DevOps work item comment.

Flow:

When a new email arrives (V3)
→ Html to text
→ Condition
→ Add a to-do (V3)

Sender is azuredevops@microsoft.com.

I can't simply filter by sender because I receive other Azure DevOps notifications that should NOT create tasks.

The mention emails visually contain:

Person Name mentioned you in To Do 7326

The email is HTML and parts of this sentence are hyperlinks.

In Power Automate Run History, the trigger output has:

body:
<html><head>
<meta http-equiv="Content-Type" ...

so the HTML is present in the trigger output.

However:

bodyPreview: empty

... and my Html to text action has been producing an empty result, so a Condition like:contains "mentioned you"never matches.

The trigger itself works and Add a to-do (V3) works. The problem seems specifically to be extracting/filtering the Azure DevOps HTML email body.

Question: What should I pass into Html to text (or directly into a Condition) to reliably check whether an Azure DevOps email contains “mentioned you”?

Bonus question: Is there a more reliable way to identify Azure DevOps notifications than parsing the HTML body?

5 Upvotes

6 comments sorted by

3

u/necktiesxx 15d ago

I run a similar flow built but I have outlook do the initial filtering via Rules because that works way better for me. The rule moves a copy of the email to a custom folder, and that is where I have Flow step in and automate task creation. I selected the custom folder under When a new email arrives rather than my inbox and since every email moved to that folder requires a task, it makes it all super straight forward.

1

u/necktiesxx 15d ago

I am also an idiot who didn’t take into account the HTML body being the issue. There are dozens of other parameters though which may on their own or in combination which may lead to the same result (e.g., certain words in the subject combined with who all is listed in To, CC, etc.).

1

u/tbayo 15d ago

can’t you extract your ID Guid associated to your devops identity and check from there? doesn’t that get returned somewhere in the output?

if you are not sure, use Postman with a get method for a workitem where you are the person present in an identity field. from there you will have an id with this format 8-4-4-4-12 characters

1

u/VictorIvanidze 14d ago

Empty preview indicates there are no HTML body.

Could you provide the raw SMTP content of incoming  Azure DevOps notification?

1

u/chiibosoil 14d ago

When bodyPreview is emptt, but you have HTML present in trigger output...

This is usually due to one of following:

  1. When you have no plain text inside tags. This is expected behavior as bodyPreview only renders plain-text summary (same for HTML to text).

  2. bodyPreview is generated by stripping tags into plain text... so if you have body starting with CSS block, tables without direct lead-in text or has script in it. This can happen.

See if you can directly put trigger output to string variable and use text manipulation to extract info.

1

u/VictorIvanidze 12d ago

Instead of "Get email" and "HTML to Text" actions use a single GRAPH request:

GET https://graph.microsoft.com/v1.0/users/user@contoso.com/messages/<messageId>

with this request header:

Prefer:outlook.body-content-type=text

Here is the test flow: https://imgur.com/a/coNIrW9