Missing email notification
HTTP Connector Outlook Connector Power Automate
Manish Solanki  

How to post an alert in Teams for unresponsive email?

Use Case

Recently, I came across a post in community for posting an alert in MS Teams if an email in shared mailbox is not responded within a specified period of time. The flow will monitor each email received in shared mailbox and respond accordingly.

Scenario

We have a shared mailbox where an email needs to be responded within 20 minutes. If email is not responded to after 20 minutes of its arrival, then a notification should be triggered on MS teams:

Solution

1. Create an automated flow & choose “When a new email arrives in a shared mailbox” as the trigger. Set the folder as “Inbox” or if you have set the rule then accordingly change it. If you need to monitor particular email then you can use different filters like ‘To’, ‘From’, ‘Subject’, contains attachments etc. Those can be set in the trigger:

2. Next, add “Delay” action to pause the execution of the flow. Set the time to 20 minutes. You can change the pause duration as per the user case:

3. Post delay action, add “Send an HTTP request” action to check if someone has sent the response of that email. We will be checking in Sent folder if response has been submitted. To make sure that respond for an email exists in ‘Sent’ folder, we will loop up the reply using ‘Conversation Id’ which does not change and remain same as original received email. We will be using graph API to check the reply or response of an email:

https://graph.microsoft.com/v1.0/users/sharedmailbox@xxxxx.onmicrosoft.com/MailFolders/AQMkAGQ2YzgxNDUyLTg0YmYtNDU4Mi1hYzlhLTg5NTNkMmUxMmFlNQAuAAADL9NdXOhtTUqVUFxjKt1mJAEA-okhOtWdak2rNk5s6JiojgAAAgEJAAAA/Messages?$filter=conversationId eq '@{triggerOutputs()?['body/conversationId']}'&$top=1

Replace sample shared mailbox email address with actual email address in the above API. But the question is how to get the ID of the sent folder? For that, add “Get emails” action, select ‘Sent Items’ in folder parameter and enter the shared mailbox in ‘Original Mailbox Address’ parameter:

On the right side, click (…) and select “Peek code” from the sub menu:

Get the Id of the “Sent Item” folder as shown below:

Note: The underling part is the Id which we need to use in graph API call for ‘Sent’ folder.

You can delete the “Get items” action once we have Id of the folder.

4. Following graph API call, we will add “Condition” action to check if “Send an HTTP request” action returns any result. We will check if length of array returned is zero then we will post a reminder message to team for sending reply. To get the length of an array, we need to use expression with length function. Expression needs to be added in the expression box:

length(outputs('Send_an_HTTP_request')?['body/value'])

In “Yes” block, we will add “Post message in a chat or channel” to notify the team for the missing reply:

<p>Hi Team,</p><br><p>Following email has not been responded:</p><p>Subject: @{triggerOutputs()?['body/subject']}</p><p>Received: @{triggerOutputs()?['body/receivedDateTime']}</p><p>From: @{triggerOutputs()?['body/from']}</p>
<p>Please take the necessary action asap.</p><p>-Digital Worker</p>

Output

Email received in shared mailbox:

MS Teams notification when this email was not responded in 20 minutes:

Conclusion

This solution can be implemented for the following use cases:

  • Using the above solution, users or group can get the real time notification for emails for which reply has been missed.
  • This solution can be scheduled to notify about the emails that are in pending state and needs to be responded to.
  • The solution can be used for reminding users for replying to urgent emails.

2 thoughts on “How to post an alert in Teams for unresponsive email?

  1. Balajied Kynsai Tang

    Hi Manish,

    I recently posted in the Power Automate community. Will your solution solve some of my issue that I am facing with Power Automate?

    https://powerusers.microsoft.com/t5/General-Power-Automate/Cannot-get-alerts-for-emails-in-a-shared-mailbox-that-does-not/m-p/2603388

    1. Manish Solanki

      Hi Balajied,

      Did you try the solution? I think it solution should fit there.

      Thanks

Leave A Comment