Set the custom Focusing status in Microsoft Teams from To Do using Power Automate

I am happy to announce that I have a free NoCode alternative for setting the Focusing status in Microsoft Teams! This is a follow up post to one of my most popular blog posts in 2020, Set the custom Focusing status in Microsoft Teams using Power Automate invoked through PowerShell.

Update 06.10.20: Updated the flow to better handle expected failure, should now exit as success if the task has no number. Download and import the Power Automate flow from GitHub. Found a logical issue 08.10.20, the Flow is now updated👍

The Focusing custom Teams status can only be set by MyAnalytics via a calendar event called ‘Focus time‘. I have not been able to recreate this calendar event type manually, so it must be something in the header. During a ‘Focus time‘ calendar event, the Teams client sets the status to Do Not Disturb with a custom name called Focusing. Personally, I don’t like the current way MyAnalytics schedules this event since it is two hours long and weeks in advance. I need a way to set this status at the time I am focusing, to mute distractions and tell my peers that I am in a focus, deep work, flow Pomodoro sprint. This is why I created this routine.

Here is how to get started with Focusing custom Teams status

  • Create the ‘Focus time‘ calendar event in MyAnalytics
  • Navigate to your personal dashboard at https://myanalytics.microsoft.com/
    • See prerequisites further down in the blogpost
  • Click on Focus in the left menu
  • Click book now to get a ‘Focus time‘ event in your calendar which will set your Teams client in Focusing status for the duration of the calendar event
  • When this is done, it is possible to leave the plan under plan configuration or by using the below link, to avoid getting future calendar events like this.

How it works and watch the YouTube explainer video

Watch the YouTube video where I demonstrate how the routine works and how to get started

Instead of using the premium HTTP request trigger, I now use the free NoCode Microsoft To Do trigger. When a new task is created, the Power Automate flow runs, finds your default calendar, finds an existing Focus time calendar event in your language and sets the time for your Pomodoro sprint duration. It even has an option to use IFTTT to mute your phone during the sprint.

Background

I am a Pomodoro Technique enthusiast. During a Pomodoro sprint it is important to mute distractions. This worked fine with custom presence states in Skype for Business, which is one of my most popular blog posts to date. I also published a very popular blog post on a routine to use HTTP request trigger in Power Automate to set the Focusing custom mode in Microsoft Teams. The problem with that routine is that it required coding and you needed to trigger it in PowerShell using a premium trigger. To Do triggers are included in most Office 365 SKU’s. Download and import the Power Automate flow from GitHub to see how the flow is built.

  • Make sure all prerequisites are met as the described below
  • Open Microsoft To Do
  • In any list, you create a new task and in the subject you put the time interval you want to do a Pomodoro sprint to achieve deep work/flow state/focus time
    • This technique even works from mobile and web!
    • I recommend you create a Pomodoro list in To Do to keep them all in the same place and so they don’t clutter your actual Tasks
  • Up to 3 minutes later, the Power Automate flow will trigger
    • I have tuned the timers in such a way that both the calendar event and the IFTTT trigger will start at the time you created the To Do task, and not when the flow is triggered
  • The flow will then access your primary calendar and create a copy of the current Focus time event and call it “Old Focus time” for historical purposes
    • This works regardless of language of the calendar and the Focus time calendar event, I check for primary calendar and use criteria to find the correct calendar event
  • Then the flow will get the latest Focus time event and update it with the time your To Do task was created and end the event using the number you put in the To Do task subject
  • When the calendar event is created, Teams will almost instantly update it’s status and put you in to the custom Focusing status, which has the same capabilities as if you set yourself to Do Not Disturb
  • When the calendar event is done, you will revert back to the correct status for your current time, busy if you are busy in calendar or available if you do not have anything else in your calendar
  • Now you can go to your meeting or evaluate which task is most important for you and trigger a new Pomodoro sprint :)

Prerequisites

  • Calendar must be in Exchange Online
  • You must have MyAnalytics as part of your license and enabled
    • Schedule 1 period with MyAnalytics to get the calendar event
    • Available in Enterprise SKU’s
    • I recommend to turn it off again after the first run, so that you calendar does not get flooded with weekly Focusing time events
  • Download and import the Power Automate flow from GitHub
    • Go to Power Automate in https://portal.office.com
    • Navigate to My flows and click Import
    • No changes are needed in the actual flow after import is finished
  • Find one of your Focus time calendar event and set priority to low
    • This can only be done in Outlook desktop client
  • In order to find the correct calendar entry we are checking for the following
    • Priority low
    • Category: Green Category
      • In my tests the category will be named Green even though you are using a different language
    • We find the first one and edit that event, to make sure we are not editing all events
      • The flow stops after one event is edited
  • Optional bonus, not required
    • If you install the flow app on your mobile, you can get a notification on you mobile when the Pomodoro sprint starts and when it stops
    • You an use that notification to trigger an IFTTT action on Android and iOS to set them to do not disturb at the start and turn it off again
    • I even use the IFTTT trigger to control a hue light in my office, set it to red during the Pomodoro sprint and green when finishing :)
    • Read more about IFTTT triggers for pomodoro sprint here
    • In order to enable the IFTTT part of the flow, you need to go in and edit it and set the IFTTTIntegration variable to 1. It is set to 0, disabled, by default

Power Automate techniques I used to accomplish this flow

In the coming weeks I will publish separate blog posts on how I created a universal flow which works out of the box in any environment. In the meantime you can download the flow from GitHub and take a look

  • How to find the default Outlook calendar for a person regardless of language
  • How to find the default Microsoft To Do tasks list for a person regardless of language
  • How to find a specific calendar event based on category
  • How I used ticks() to find time difference in Power Automate and what I used it for
  • Substring() techniques in Power Automate
  • If() in Power Automate
  • Math is hard in Power Automate, here is how i used sub(), div(), addminutes() and length()
  • Named variables and comments in Power Automate

Use Power Automate to send Teams messages to To Do #NoCode

I am a productivity enthusiast. I use Microsoft To Do for my individual task management. When someone has a task for me in Microsoft Teams I need to get them in to To Do. MVP Vesa Nopanen created a Power Automate routine for doing this which works great. In his blog post, he talks about how to create it and how to share it with select users within your organization. I have tuned this routine to make it universally available so that no changes to the code is need for it to run in your organization. How? Read on

I created the universal routine which you can download from GitHub and try for yourself. Just import it, authorize access to Microsoft Teams and Microsoft To Do and you are good to go. Check out Vesa’s blogpost for how to share it in the organization

Originally the routine checked for the name of your tasks folder, but I found a way to do that programmatically, since the name of the folder is different depending on your language. The flow will look up the lists in user context and from there we can check which is the default one. Tasks is always the default one.

I did one more thing. When capturing the text to go in the task, I wanted to limit the length of the subject to 150 characters.

  1. I had to convert the output from Teams to plain text
  2. Then I checked the length of the body
    • if it was short than 150 characters, I used that as length,
    • if the body was more than 150 characters I limited it to 150.
    • if(lessOrEquals(length(outputs(‘Html_to_text’)?[‘body’]),150),length(outputs(‘Html_to_text’)?[‘body’]),150)
  3. Finally I created a string variable which is no longer than 150 characters and used it in the subject.
    • substring(outputs(‘Html_to_text’)?[‘body’],0,outputs(‘Compose’))

That’s it, simple and effective. You can download the flow from GitHub, make sure you read the original blog post for full details. MVP Yannick Reekmans has a different take to accomplish this using a graph approach. You still need the above routine to get the default task list.

When importing the flow, you need to have these connectors available so that you can complete the import. All connectors are part of your Office 365 subscription

Set the custom Focusing status in Microsoft Teams from PowerShell using Power Automate

I am a Pomodoro Technique enthusiast. During a Pomodoro sprint it is important to mute distractions. This worked fine with custom presence states in Skype for Business, which is one of my most popular blog posts to date, on a daily basis. With Microsoft Teams, this has been a challenge, until now.

The Focusing custom Teams status can only be set by MyAnalytics via a calendar event called ‘Focus time‘. I have not been able to recreate this calendar event type manually, so it must be something in the header. During a ‘Focus time calendar event, the Teams client sets the status to Do Not Disturb with a custom name called Focusing.

Here is how to get started with Focusing custom Teams status

You can schedule such a calendar event at will using PowerShell and PowerAutomate

Personally, I prefer to manually control when my Teams client gets set to Focusing state. MyAnalytics schedules the calendar event as two hours long when calendar is open and weeks in advance. I needed a way to set this status at the time I am of my choosing when I was actually focusing, to mute distractions and tell my peers that I am in a focus, deep work, flow Pomodoro sprint. I found a way to use Power Automate to control set the Focusing status at will.

The Teams Focusing status fits well with the PowerShell Pomodoro Timer. Update 05.10.20: the status updates instantly after the calendar event is added to your Outlook

Watch the 3 first minutes showing the focusing status in action!

How I solved it

I trigger a Power Automate flow using a HTTP request trigger using Invoke-WebRequest in PowerShell. The flow takes two inputs, duration and a secret. If the secret is correct, to make sure the flow can’t be easily hacked, it gets my calendar and searches for calendar event with subject ‘Focus time’. It takes the first entry and changes start time and stop time for the event using the duration I have set, usually 25 minutes. Now I have a ‘Focus time’ calendar event that is set at the same time as my Pomodoro sprint with the same duration. After 1-3 minutes, my status will be updated to Focusing. After 25 minutes, plus 1-3 minutes, my status will be reset. BOOM, how cool is that!?

Prerequisites

Update 05.10.20: I have created a free way to do this using Microsoft To Do task as a trigger. No need for code adjustment, just download and use it. Read more here! If you want to use premium Power Automate trigger and PowerShell to set the status keep on reading :)

Update 08.01.21: Together with MVPs Dux Raymond Sy and Loryan Strant, I have created a Pomodoro YouTube series where we discuss the Teams custom focusing status and multiple ways to solve this. Check it out!

  • Calendar must be in Exchange Online
  • You must have MyAnalytics as part of your license and enabled
    • Schedule 1 period with MyAnalytics to get the calendar event
    • Available in Enterprise SKU’s
  • You must have Power Automate license and ability to use Premium triggers
    • The trigger used is HTTP request and is a Premium trigger
    • You may find that you can use other free triggers as well
    • Premium triggers are included in Dynamics 365 SKU’s
    • Premium triggers are not included in Microsoft 365 SKU’s
    • The standalone $15 Per User plan can run Premium triggers
  • If you want to use a trigger included in your Office 365 plan, check out my other method, using Microsoft To Do task as trigger

Creating the calendar event and importing the Power Automate flow

  • Create the calendar event in MyAnalytics
  • Import the flow in your Power Automate
    • Watch the full walkthrough of the import of the flow at 3:39 in the YouTube video
    • Download the HTTPSTriggerUniversalPomodoroFocustime.zip file here
    • Navigate to your personal Power Automate dashboard at https://flow.microsoft.com/
    • Go to My flows in the left menu and click Import
    • Click Upload and choose the zip file
    • To be able to complete the import you must click the wrench in the first line and choose Create as new under Setup
    • Next you must create the Outlook connector by clicking on the wrench in the second line for Related resources
      • Click Create new
      • Scroll down to Office 365 Outlook, click Create and authenticate as your user
      • Now you have created the Outlook connector, go back to the flow import website and select you new connector and Save
      • Import the flow by clicking Import
      • The import should be successful, navigate to My flows
    • Edit your new flow called HTTPSTriggerUniversalPomodoroFocustime.
    • Now, let’s go through it and update the flow for your environment

Configuring the Power Automate flow

Click Edit on the flow and expand When a HTTP request is received and copy the HTTP POST URL and save it for later

Expand Condition and change MySecret to your own and take note of it

If no is there to trigger if the secret is wrong, it is a small security measure so that people not easily can steal you flow URL, but they also need the secret, or you can change it if it does get lost

That is the only change you need to make to the flow because the flow will find your default calendar. Since the name of your primary calendar may be different in your language, we are looking for the calendar for your user with isRemovable=False

But there is one more thing, we want to edit one of the calendar ‘Focus Time’ calendar events created by MyAnalytics. We want to set the event to workingElswhere or has priority of low. In this way we have more control over which event we are manipulating.

That’s it! You are now ready to invoke your flow. In PowerShell you need to run the following code

[int]$Minutes = 25 #Duration of your Pomodoro Session, default is 25 minutes
[string]$Secret = "MySecret" #Secret for the flow trigger
[string]$AutomateURI = "YourFlowTriggerURI" #The URI used in the webrequest to your flow


#Invoking PowerAutomate to change set current time on your Focus time calendar event, default length is 25 minutes
    $body = @()
    $body = @"
        { 
            "Duration":$Minutes,
            "Secret":"$Secret"
        }
"@
Invoke-RestMethod -Method Post -Body $Body -Uri $AutomateURI -ContentType "application/json"

Go back to Power Automate and validate that the flow ran, check your Outlook calendar that the ‘Focus time’ event was moved to now the status should change almost instantly. When the calendar time is over, your status will be reset and you are available again.

The practical approach with the Pomodoro PowerShell timer

With the ability to control the status in Teams, I believe the Pomodoro PowerShell timer is feature complete. One thing is to be unavailable and reduce distractions, but it is very important to automatically become available again. The reason for WHY you would use this kind of timer and automation is to avoid getting distracted which breaks your flow and deep work. Research shows that it takes between 7-30 minutes to get back in to flow after you have seen just one email or message. Here is what the script does

  • Starts presentation mode to block popups on your computer
  • Hides badges on taskbar so that you do not get distracted by seeing that you have a new mail, task or chat
  • Opens you favorite flow and deep work Spotify playlist so that you do not spend time figuring out what to listen to
  • Uses IFTTT to mute your phone, works with Android and iOS
  • Finally set your status in Teams to Focusing
  • After the Pomodoro sprint is over, everything will be turned back on again
  • Watch my demo (and live commentary) of the script in the YouTube video :)

Below is a sample code to run the Start-SimplePmodoro.ps1 script which you can download from GitHub

Start-SimplePomodoro `
-SpotifyPlayList spotify:playlist:XXXXXXXXXXXXXXXXXX `
-IFTTTMuteTrigger pomodoro_start `
-IFTTTUnMuteTrigger pomodoro_stop `
-IFTTTWebhookKey XXXXXXXXX `
-Secret YourFlowSecret  `
-AutomateURI YourAutomateURI `

Watch how to get started with the Pomodoro PowerShell script at 3:39 in the YouTube video

Why is it important to automatically become available?

You have been gone for 25 minutes, use the pause to check if anyone has been trying to reach you, re-prioritize your tasks, get more coffee and then dive in to a new Pomodoro sprint. After 25 minutes it is OK to get distracted, but if nothing happens, just stay in the flow you jump started and get stuff done. Download the Pomodoro PowerShell timer from GitHub

How to use Microsoft Flow to move email to OneNote

The send to OneNote plugin in Outlook for PC and Mac is awesome. The problem is when you are not in front of a computer and need to tag an email for processing later when you are on other platforms. My approach to solve this is to use flagging of email and send that to my collection section in OneNote using Microsoft Flow. In that way, I know when I have processed it and I know I can find it again in OneNote for when I process my OneNote and create actionable tasks.

Here is how to get started with using Microsoft Flow for moving flagged emails to your Collection section in Microsoft OneNote that is stored in OneDrive for Business in Office 365.

  1. Log on to your Office 365 portal
  2. Click on the Flow icon to get started
    • requires that Flow is enabled for your tenant and your user
  3. Search for Outlook, because that is our trigger
  4. Choose the trigger for when flagging an email in your inbox
  5. Click on Next Step and search for OneNote (Business)
  6. Choose create page in section
  7. Choose the notebook that is stored in OneDrive for Business
  8. Choose the section you want to store it in, which should be your collection section
  9. In order to get a good input from the email you need to paste in some HTML code in order to get subject as title and more info from the email in to OneNote
  10. From here, save the flow
    • it takes 10-15 minutes for first run
    • The free version runs every 15 minutes, the Office 365 flow version runs every 5 minutes
    • For Office 365 the number of times a flow can run is tenant wide and is aggregated by the number of user licenses in the tenant and is 2000 times per user per month
    • One user can consume a lot more runs than 2000, but the average is 2000 per user per month
    • Read more her: https://flow.microsoft.com/en-us/pricing/#plan-feature-table
  11. The flow with flagging of emails are only run when you actually do the flagging, so you will only consume a run when you actually do the flagging

Check out my OneNote LifeHacks video from Ignite on how to set this up.

References

Looking for coaching on being more productive with OneNote and get more stuff done, connect with me at CloudWay