Intermediate | Flow of the Week: Sending a Welcome Email to New Flow Users

 

This post comes from The Ultimate Flow Warrior, Kent Weare.

Kent is a Senior Manager of Enterprise Architecture and Integration at Inter pipeline where he leads a team of architects, integration and business intelligence developers. You can follow Kent on twitter and his weekly Middleware Friday vlog:  http://www.integrationusergroup.com/middleware-friday/

Introduction

The Power platform management connectors have been mentioned on Flow blog before, discussing how you can use these powerful connectors to automate PowerApps and Flow governance. These connectors are not only powerful, but allow admins to be efficient with their time, just like flow makers as they seek to extract more out of their work day.

In this blog post, we are also going to leverage these management connectors, but through a different lens. In this case, we want to focus on how we can ensure new users to the flow service have the resources they need to be productive and successful with Microsoft Flow.

In my experience, when Office 365 is rolled out within an organization, users become intrigued with all the new tools they now have access to. As a result, they start clicking around and end up in Microsoft Flow. Their curiosity may also land them in the Microsoft Flow templates area where they try out some of the popular templates. But, beyond some of the simpler templates, end users need additional resources to tackle their use cases. In this post, we will send users a welcome email which includes validated resources and even company specific resources that have been made available to help them with their learning journey.

Pre-requisites

This solution relies upon the Power platform management connectors and requires elevated permissions and licenses. Please refer to this blog post for more details. This solution also assumes you have an Office 365 group created and you have the rights to add members to this group.

Building The Flow

We want our process to look for new flows every day, so we will setup a Recurrence trigger that runs every day at 3pm local. In addition, we will initialize 2 variables that will help us with our processing, including:

  • reportingPeriod – is an Integer and has an initial value of -1. This will be our window that we will look back on to see if we have any new flows created. If we want to run this process weekly, then a value of -7 would be appropriate.
  • reportingPeriodTicks – which is also an Integer and represents the amount of ticks that exist for our reporting period. The value of this integer is achieved through an expression of ticks(addDays(utcNow(),variables(‘reportingPeriod’)))

The next step that we need to perform is adding a Get Environments action using the Power platform admin connector.

Naturally, this call will return a list of environments and subsequently add an Apply to each loop to our flow.

We will now List Flows as Admin and pass in the Name value of the current environment that we are iterating through in our environments loop.

Listing all flows within an environment will naturally create another Apply to Each loop. Within this loop we now want to check if we have any new flows in this environment. To do this, we will check to see if the ticks of flow are greater than the ticks value of our reporting period that we established earlier. As a result, we will check to see if an expression of ticks(item()?[‘properties’]?[‘createdTime’]) is greater than our reportingPeriodTicks variable.

If our flow was created before our reporting period, that is ok, we won’t perform any additional actions. If our flow was created after our reporting period, then our logic will travel down the ‘green’ path.

We don’t want to send an email for each new flow. So we need to track new user information somewhere. One place could be SharePoint, but I opted to store it in an O365 group as there may be other opportunities to leverage this group in the future where we need a security context.

Our next steps include:

  • Listing O365 group members
  • Getting the O365 User (UPN) for the creator of the flow

We now know that we have a flow that has been recently created and the owner and related metadata for that flow. But, we don’t know if our user exists in our O365 group, so that is our next step. To accomplish this, we will use a condition that will take our Office 365 group membership and turn it into a string by using the following expression: string(body(‘List_group_members’)). Next, we will see if it contains the name of our User Principal Name (UPN).

If our UPN is not in our group, we now need to add them by using the Office 365 Group connector. Finally, we can go ahead and send an email to our new member using the Office 365 Email connector.

Our flow is now complete and should look like the following:

Testing

When a new user creates a flow and our recurrence trigger fires, they should receive an email that looks like the following:

Conclusion

In this blog post we leveraged the Power platform management connectors to automate a business process. But, this time it was different than our previous management connector use cases. Instead of focusing on governance processes, we focused on an Organizational Change Management (OCM) process instead, that provides new users with resources that they can leverage to become more comfortable with flow. While the role of IT department does include protecting the company’s data sources, educating and empowering end users creates outcomes for the company, which should also be a top priority for an IT group.