Consolidating emails in Power Automate

This post will demonstrate how you can easily to about consolidating emails in Power Automate.

You can easily consolidate a number of emails into a single summary email in Power Automate. For the Power Automate app from my previous Blog post this just amounts to replacing our Compose component with a “Create HTML Table” component. The “Create HTML Table” component takes an array of items and constructs a HTML Table for these items, where each item is represented as a row in the table. As the output from this component is a HTML table the output can be used in the body of an Email that is enabled for HTML text.

The “Create HTML table” From field should be set to the expression : outputs(‘Send_an_HTTP_request_to_SharePoint’)?[‘body’]?[‘d’]?[‘results’] This formula instructs Power Automate to take the output from the “Send an HTTP request to SharePoint action” and use the “results” object contained in the “d” object which in turn is contained within the “body” object.

Our summary email requires only one table column which we can name as “Title”, and we must set this column’s value to the expression : item()?[‘Title’]. This formula instructs Power Automate to use the Title property from each array item in the results object.

Finally we need to set the Subject of the Email so something like “Summary Email” and its Body to the output of the “Create HTML Table” component

When this app now executes you should receive an email like shown in screenshot below, clearing demonstrating that consolidating emails in Power Automate has taken place.

REST Filtering in Power Automate apps

This post will demonstrate how you can apply REST Filtering in Power Automate apps.

Our Power Automate app to date has a design that emails us a custom email for every document within our document library at a regular interval. This Blog post will show you how modify this app’s design so we only receive email notifications for the latest uploaded documents.

Our current Power Automate app contains the following REST query: /_api/web/lists/getbytitle(‘Documents’)/items

This query will bring back all the items in our Document Library. We need to modify this query in order to filter out unwanted items. We can achieve this using the REST query filter syntax – see further REST query syntax here.

To bring back documents created after the 26th of March 2016 we would use the REST query: /_api/web/lists/getbytitle(‘Documents’)/items?$filter=Created ge datetime’2016-03-26T00:00:01Z’

However, you probably require our filter to use a date that is related to the frequency that our Power Automate app is run. For example, if the app is run daily we would like the filter to be the last 24 hours (i.e. no less than 1 day from now). We can achieve this by adding a Power Automate dynamic expression in place of the xxxxx text in: /_api/web/lists/getbytitle(‘Documents’)/items?$filter=Created ge datetime’xxxxx’

The dynamic expression for no less than 1 day from now would be : addDays(utcNow(),-1). This expression can be added using Power Automate using the “Date and time” expressions are shown in the screenshot below.

This post demonstrated how to perform REST Filtering in Power Automate to reduce the number of email notifications you receive. However, we may wish to receive just one email that summarises what documents have been uploaded since the last time your Power Automate app was run. How you can go about producing this summary email is the topic of my next Blog post.

Scheduling in Power Automate apps

This post demonstrates how you can introduce scheduling in Power Automate apps

The Out Of the Box (OOTB) SharePoint “Alert Me” functionality contains an option to specify when you wish to receive your email notifications (see screenshot below). This Blog post will outline how you can schedule your email notifications if you decided to customise your email notification body using Power Automate

Power Automate apps are triggered by some event and once triggered they perform their prescribed actions. In the Blog post Creating your own “Alert Me” email, the Power Automate trigger was “When a file is created (properties only)”. This trigger results in the app’s actions (i.e. emails being sent) being immediately executed upon a documented being uploaded to the specified document library. To schedule the email notifications we must replace this trigger with Power Automate’s scheduling trigger

It is not possible to directly replace a Power Automate trigger. This is because the actions prescribed after the trigger are too dependent on the trigger itself. This means we need to create a new Power Automate app to schedule our “Alert Me” notifications.

Within Power Automate, select the “Create” menu option and then the “Schedule Flow” blank template option. Then name your app and specify how often you wish the app to be triggered – you have intervals of seconds, minutes, hours, days, weeks and months!

Then for the app’s next step (i.e. action) select the “Get my profile (V2)” component. We will need the data from this component later when we are composing our notification email.

Then for the app’s next step select the “Send an HTTP request to SharePoint” component.

Within the component’s “Site Address” field specify the site address that contains your document library, and within the compnent’s “Uri” field add the text “_api/web/lists/getbytitle(‘Documents’)/items” (i.e. replacing the library title of “Documents” with the name of your custom Document Library). This uri performs what is called a REST query on the SharePoint Document Library to return information on all the items in the Document Library.

Then for the app’s next step select the “Apply to each” component. This component will allow us to loop through, one at a time, each of the Document Library items returned from the REST query.

Within this component’s “Select an output from previous steps” field add the expression : outputs(‘Send_an_HTTP_request_to_SharePoint’)?[‘body’]?[‘d’]?[‘results’] This expression obtains just the Document Library item information from the REST query.

Now within the “Apply to each” component block add a Compose Data Operation action. We are going to configure this action to extract the Document “Title” for the current item. (note : You may wish to add several Compose action to extract additional item information you wish to include in your email notification).

Within the Compose Inputs field add the expression : items(‘Apply_to_each’)?[‘Title’]

Finally, add a “Send an email (V2)” action below the Compose action and configure it to use the Compose Title value. Your app should now look as shown below and will run at intervals as you have scheduled emailing you Title information on all the Documents within your Document Library.

This post demonstrated scheduling in Power Automate apps by using the Scheduling trigger to fire when our workflow email notification app starts. Over time the number of emails from the Power Automate app will increase as additional documents are added to the Document Library. You are probably only interested in the latest documents that have been uploaded. To achieve this you need to add a filter on the REST query of your Power Automate app and this is the topic of my next Blog post.

Filter content in Power Automate

This post demonstrates how you can filter content in Power Automate.

The Power Automate “Alert Me” app created in my previous Blog notifies you whenever any document is uploaded to your SharePoint Document Library. What if you wish to be notified of only certain files being uploaded? You could use the approach outlined in my first Blog. Alternatively, you can edit the Power Automate “Alert Me” app.

Editing a Power Automate app is easy as it amounts to configuring added components ( i.e. no coding skills are required).

To filter content in Power Automate we can use Power Automate’s Condition component. Within the app’s edit canvas hover over the line between the “Get my Profile” and “Send an email” blocks. This will reveal an option dialog and from it select the “Add an action” option.

Then from the “Choose an action” block select the Condition Action.

You should now see an Condition block and a block if the Condition block’s criteria is met (i.e. the If yes block) and a block if the Condition block’s criteria is not met (i.e. the If no block). Now drag the “Send an email” into the If yes block.

All that now remains is to specify the Condition block’s filter criteria. Place your cursor within the Condition block’s “Choose a value” textbox reveals a selection dialog. This dialog allows us to select the filtering field criteria for the document library. These are the fields in the “When a file is created (properties only)” category of the “Dynamic Content” group.

Once you have specified your filtering criteria make sure you save you design and you should have filtered customised email alerts on your document library.

My next Blog post will outline how you can schedule these Power Automate email notifications.

Creating your first Power Automate app

This post discusses how you can create a Power Automate app to produce an alternative email to SharePoint’s “Alert Me” email.

SharePoint’s “Alert Me” email content has a standard format containing the custom fields of the SharePoint document or list item – see screenshot below. What can you do if this format is unsuitable?

This is a situation where you can use Microsoft’s Power Automate App. Power Automate is an App that enables integration between software applications, and in this case it allows us to produce a custom integration between a SharePoint list/document library app and Microsoft’s emailing app, Outlook.

The good news is Microsoft provide a free version of their Power Automate app with O365 and this version is packed with functionality. You can access your Power Automate App from the O365 App Launcher located at the top left of your browser – see screenshot below.

The first time you access Power Automate can be a daunting one, as you can become overwhelmed by its vast range of options. However, you do not need to understand all its functionality to perform the task in hand. Select the Template link for the menu on the left and type in “send a customized email” in the Search Box and click on its Search Button (i.e. the magnifying glass) to reveal a suitable template for our needs.

If you want a customised email when a file is added to a document library select the “Send a customized email when a new file is added” template. Once the template is opened provide the url for your “Site Address” and “Library Name” and Save your design.

Upload a document to the document library and you should receive an email notification like the one shown in the screenshot below. However, now you have the opportunity to style this notification in the manner you require by modify the email body in the “Send an email” action of your Power Automate designed App.

This customised email notification is sent whenever a document is uploaded. If you wish to only be notified when certain documents are uploaded you need to customised the Power Automate template. This is the topic of my next Blog.