How to Send an Alert to a Microsoft Teams Chat for New P1 Emails in Your Inbox

Posted by:

|

On:

|

Today we will be discussing how to create an automated process in Power Automate to detect high-priority (P1) emails in your mailbox and notify a Microsoft Teams group chat. By leveraging the “When a new email arrives (V3)” trigger, you’ll ensure your support or operations team is promptly alerted whenever a critical case arrives.

Introduction

When your team relies on email notifications for critical issues, response time is everything. By using Power Automate to post a message in Microsoft Teams whenever a new “P1” (Priority 1) email arrives, you can:

  • Ensure no urgent case slips through the cracks.
  • Instantly alert a group chat or channel.
  • Parse details (e.g., case number, customer) for quick triage.

Prerequisites

  1. Office 365 Mailbox: Your mailbox must be licensed for and accessible by Power Automate’s email triggers.
  2. Microsoft Teams: You must be a member of the Teams channel or group chat where you plan to send notifications.
  3. Power Automate: Access to create flows in your Microsoft 365 environment.

Note: Make sure you have permissions to post messages to the target Teams chat or channel.

Overview of the Flow

Trigger: “When a new email arrives (V3)” in your Inbox.
Condition (optional): Check if the subject contains “P1 Critical Case,” or another naming pattern.
Actions:

  • Parse the subject for the case number and/or customer name.
  • Post an alert to Microsoft Teams in the relevant chat or channel with these details.

Step-by-Step Guide

1. Create the Flow

  1. Go to Power Automate at: https://make.powerautomate.com.
  2. Select CreateAutomated cloud flow.
  3. Name your flow (e.g., “P1 Email to Teams Alert”).
  4. Choose the trigger: “When a new email arrives (V3).”
  5. Click Create to build your flow.

2. Configure the Trigger

In the When a new email arrives (V3) step:

  1. Folder: Set to “Inbox” (or the folder where your P1 emails land).
  2. Subject Filter: You can leave this blank if you plan to filter using a condition. (Exact matches only—no partial/“starts with” logic is supported here.)

3. Add a Condition for Filtering

If you want to only run the flow when the subject starts with or contains a specific phrase (e.g., “P1 Critical Case”):

  1. Add a new stepControlCondition.
  2. In the condition, you can use an expression like:
@startsWith(
  coalesce(triggerOutputs()?['body/Subject'], ''),
  'P1 Critical Case'
)

If the condition evaluates to true, proceed with parsing and sending. If false, end the flow or route to a different branch.

4. Parse the Email Subject

If your subject line follows a format such as:

P1 Critical Case <CaseNumber> for <Customer> has been created at <Time>

you can automatically extract <CaseNumber> and <Customer>.

  1. Add ActionData OperationsCompose, name it ComposeCaseNumber.
  2. In the Inputs field (Expression tab), enter:
first(
  split(
    replace(
      triggerOutputs()?['body/Subject'],
      'P1 Critical Case ',
      ''
    ),
    ' for '
  )
)

This removes "P1 Critical Case " and splits on " for ". The result is the case number as the first element.

3. Add another Compose, name it ComposeCustomer.

4. Use an expression such as:

first(
  split(
    last(
      split(
        replace(
          triggerOutputs()?['body/Subject'],
          'P1 Critical Case ',
          ''
        ),
        ' for '
      )
    ),
    ' has been created at '
  )
)

This grabs the substring after " for " and splits by " has been created at ", leaving you with the customer.

Post an Alert to Teams

  1. Add an Action → search for “Microsoft Teams”.
  2. Select “Post a message (V3) (preview)” or “Post message in a chat or channel”—depending on your connector version.
  3. In Recipient (or Conversation ID), pick your Teams group chat or channel.
  4. In the Message Body, insert the output of your Compose actions (not the raw expressions). For example:
 Hey new P1 case from @{outputs('ComposeCaseNumber')}<br>
  for @{outputs('ComposeCustomer')}<br>
  Anyone available to pick this up?

Use the dynamic content picker to ensure you insert the Compose outputs correctly.

Testing and Verification

  1. Save your flow.
  2. Send a test email to your mailbox with the subject matching the P1 format.
  3. Check the Run History in Power Automate:
    • If the flow never triggers, confirm the folder and license setup.
    • If it triggers but the condition is false, verify your subject actually starts with “P1 Critical Case.”
    • Expand each step to see the Compose outputs (case number, customer).
  4. Verify your Teams chat receives the alert with the correct details.

Common Pitfalls

  • Literal Expression in Teams Message: If you see text like first( split( ... ) ) in Teams, it means you pasted the expression instead of inserting the Compose outputs.
  • No Subject: If the incoming email has no subject, triggerOutputs()?['body/Subject'] can be null, causing expression errors. Use coalesce() to avoid issues.
  • Exact Match vs. Partial Match: The Outlook trigger’s Subject Filter only does exact matches. Use a Condition step for partial or “starts with” logic.

Conclusion

By combining the When a new email arrives (V3) trigger with conditional checks and Teams actions, you’ll have a robust solution that immediately flags critical P1 emails and alerts your team. In just a few steps, you can parse the subject for key details (case number, customer) and post a well-formatted notification—ensuring your support or operations teams never miss a critical issue.


Related Resources