Tuesday 3 September 2019

Analyse and Enable Users to Adopt to Microsoft Teams early

As we are marching towards the transition phase from Skype to Microsoft Teams, let us look how you could enable/advice users to adopt to new technology early. The article helps you understand how you could automate the process of identifying users who are not of Microsoft Teams system, and sending them reminders to adopt to the latest technology. The approach explained here is one way of identifying and enabling users to adopt to Teams sooner. There are multiple ways to enable such adoptions.


Scenario


Let us first see how technically you could identify users and notify users on the usage. For this process, we will leverage Azure Logic Apps to create automated flows to identify the user pattern (usage and reports). The usage reports will be available on the Office 365 user activity reports. To access and manipulate the user patterns, we could leverage Microsoft Graph with necessary permissions.

As an example, we will consider logged in date as a parameter for this process. We will initially analyse the Microsoft team’s usage statistics on Office 365 report center and look for user logged in activity. If there are no activity present for any user, we will trigger an automated email for earlier adoption. Let us create a flow to achieve the entire process.

The below picture depicts the high level flow. In the below section, we will see each and every action in detail.
Azure Logic Apps Flow - To Identify Users not using Teams and Send Automated Mails
Azure Logic Apps Flow - To Identify Users not using Teams and Send Automated Mails

Note: I have chosen to leverage logic apps flow instead of Microsoft flow, since there is a place where we need to insert expressions which should recognize new line in the file content. This was failing with Microsoft Flow, so i have chosen Azure Logic Apps. [The expression is explained well in the article below]


Configure Azure Logic Apps Flow


The flow configuration is as follows.
  • Schedule to run the flow periodically. In this case, I have set it to run every 1 week.
  • Get user activity report of Microsoft teams using the graph API. HTTP action is used, along with active directory authentication.
    • The request will contains the parameters as shown in the screenshot below.
    • The successful response will be with 302 status, where the response contain the header. The header will have location parameter, which has URL to the actual usage report.
Get Usage Reports from Office 365 Analytics
Get Usage Reports from Office 365 Analytics

  • Get the report content: Pass on the location URL using HTTP action, to get the report file content. The content will be in binary format.
    • The below picture depicts how to get the file content.
Read the file Content from the location - redirect URL
Read the file Content from the location - redirect URL

    • Also the response status is 302. The flow will fail since there is an attempt to redirect. So this step should be configured such a way that, the flow should run even if the previous action fails. Select the configure run after option for this action, and set the below configurations.
Action to run - even if the previous action fails [this is must to ensure flow to complete]
Action to run - even if the previous action fails [this is must to ensure flow to complete]

  • Create the file on one-drive, as intermediate store in .csv format, and receive back the file content from one drive. 
    • The received content will be text format. 
    • The content will have header text in the first row, and usage statistics in the subsequent rows.

Intermediate store to store file content - Easily data is converted to required format
Intermediate store to store file content - Easily data is converted to required format

  • Initialize and set necessary variables. Use the variables to split and get the necessary data. 
    • Split the text and initialize it as array. If you use action expression, enter keyword is pressed to get the expression as the second parameter in between quotes. Else, you could use the code view on logics app, and provide the following expression as value. Please note providing \n in the expression will have different effect than you give on logics app code view.
                    "@split(body('Get_file_content_using_path'),'\n')"
    • Initialize one empty array: This array will be result array, which will contain the filtered user accounts.
Initialize and set array
Initialize and set array
  • Then loop through each items in an array, and filter the item that doesn’t contain the user last activity date. The following picture depicts for-each loop.
    • The following expressions are to check if the item contains user’s last activity date.
                    length(outputs('Compose'))
                    length(split(outputs('Compose'),','))                   
                    length(split(outputs('Compose'),',')[2])                   
                    split(outputs('Compose'),',')[2]
    • The following expression is to extract the user account’s email ID, after the conditional filtering in the previous step.
                    split(outputs('Compose'),',')[1]
    • Note: No actions with else condition in my scenario.
For-each loop to filter necessary results
For-each loop to filter necessary results

  • So previous step has created an array, which will have email IDs of all users who have not logged into the teams portal so far. In this step, create a send an email trigger, to notify users for early adoption. The below picture depicts the input parameters for the action. 
    • The expression used in the To email address will be 
                    join(variables('inactiveAccounts'),';')
    • Note: splitting the previously loaded array and joining the email addresses by semi colon.
Send an email action - with message to adopt MS Teams early
Send an email action - with message to adopt MS Teams early


Flow Runs: View of Usage Data and Triggered Email


Let us have a look, how the usage report looks. After successful run of the flow, the email will be triggered to users who have never logged into Teams..

The below picture depicts the usage report center.
Office 365 Usage Reports for Microsoft Teams Activities
Office 365 Usage Reports for Microsoft Teams Activities

The below picture depicts the triggered email.
Triggered Email
Triggered Email