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

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 IFTTT webhooks to mute your Android and iOS during a Pomodoro sprint

I am a big fan of the Pomodoro Technique and have written several blogposts on it. The goal is to reach flow and deep work in order to get stuff done. I currently use a PowerShell Pomodoro timer which

When you successfully reach the flow state, you forget about time and suddenly minutes and hours have gone by. This is why it is crucial to become available again after 25 minutes. You are entitled to a break, but even more important, people need to be able to reach you again. If you find that nothing special has happened, then you can plan a new Pomodoro sprint or join your next meeting.

The reason why you would use a timer like this to turn off distractions is to not disturb yourself. You are always just one notification away from breaking your flow. It takes between 7 and 30 minutes to get back in to flow.  it is too easy to be stuck in a semi available loop of task switching and not get any real work done. This is where IFTTT webhooks comes in to play.

IFTTT stands for If This Then That. By sending a web message to IFTTT you trigger an action. It is not easy to get started with but the benefits are worth the effort. To be able to easily mute your phone and turn it back on again after 25 minutes is the goal, if you don’t do this, you have the potential of breaking you flow from a notification on you phone.

The final result, iOS phones goes to Do not Disturb during a Pomodoro sprint

Setting up IFTTT

  1. The webhook URL key
  2. Android triggers and Android setup
  3. iOS triggers and iOS setup
  4. Using the triggers in the Pomodoro script
  5. Create a shortcut to the Pomodoro script

The webhook URL key

  • Create an IFTTT account or log in with your existing account
  • Go to Settings on the Webhooks service page
    • If this is the first time you are setting up a webhook, click connect
  • Copy the key at the end of the URL, as you see mine is
  • Save your key as we are going to use it as the IFTTTWebhookKey in the Pomodoro script

Android triggers

  • We need two triggers for Android MuteAndroid and UnMuteAndroid
  • First lets create the MuteAndroid trigger
    • Go to Create
    • Search for webhook and select it
    • Use MuteAndroid as Event Name
    • Search for Android and select mute and set vibrate to No
    • Finish the setup
  • Now create the UnMuteAndroid trigger
    • Go to Create
    • Search for webhook and select it
    • Use UnMuteAndroid as Event Name
    • Search for Android and select mute and set vibrate to Yes, personally I do not use sound on my phone, only vibrate
      • If you want sound you should use the Set Ringtone Volume action
    • Finish the setup
  • Install the IFTTT app on your phone and log in with the same user
  • That’s it you are now ready to mute and unmute your Android from PowerShell
    • You can test it by using the following command
    • Invoke-RestMethod -Uri https://maker.IFTTT.com/trigger/MuteAndroid/with/key/IB4In0nMeJq7pcUa6VTtQ -Method POST -ErrorAction Stop
  • In the Pomodoro PowerShell script the following values are now available
    • $IFTTTMuteTrigger = MuteAndroid
    • $IFTTTUnMuteTrigger = UnMuteAndroid
    • $IFTTTWebhookKey = IB4In0nMeJq7pcUa6VTtQ

iOS triggers and iOS setup

  • We will not install the IFTTT app on iOS, instead we will use the two apps Shortcuts and Pushcut
  • We are not going to mute the phone, but set it to Do Not Disturb
  • Pushcuts integrates with IFTTT triggers, but we need to click the notification popup on the phone or Apple Watch in order to active Do Not Disturb
  • Start with installing Shortcuts
    • Create the Do Not Disturb shortcuts as shown in the GIF
  • Install Pushcut
    • First import the shortcuts
    • Then create notifications for iOSMute and iOSUnMute and choose the shortcuts as actions
    • Test the notifications, note that you have to tap the notification for the phone to go to Do Not Disturb
  • In IFTTT you need to create the iOSMute triggers
    • Click create and choose webhook
    • in Event Name call it iOSMute
    • as action, search for and choose Pushcut
    • The first time you need to connect IFTTT to Pushcut using the QR code as shown in the GIF
    • After you have connected IFTTT to Pushcut, choose notification, iOSMute and the device you want to send the notification to
    • Click finish
  • In IFTTT create the iOSUnMute trigger
    • Click create
    • Search for Webhooks and call it iOSUnMute as Event Name
    • As action, choose Puschut, notification, iOSUnMute and select the device you want to push the notificaiton to
    • Finish to save Applet
  • That’s it you are now ready to mute and unmute your Android from PowerShell
    • You can test it by using the following command
    • Invoke-RestMethod -Uri https://maker.IFTTT.com/trigger/iOSMute/with/key/IB4In0nMeJq7pcUa6VTtQ -Method POST -ErrorAction Stop
  • In the Pomodoro PowerShell script the following values are now available
    • $IFTTTMuteTrigger = iOSMute
    • $IFTTTUnMuteTrigger = iOSUnMute
    • $IFTTTWebhookKey = IB4In0nMeJq7pcUa6VTtQ

Using the triggers in the Pomodoro script

  • Download the Start-SimplePomodoro.ps1 from GitHub
  • Open the script in your favorite PowerShell editor
  • Scroll down to the bottom of the script and populate the run command as shown in the GIF
  • Save the script and run it from PowerShell, remember to navigate to where you stored the script
Add your Spotify playlist, your triggers and IFTTT keys
The result, you need to tap the notification from Pushcut in order to set the phone in DND

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

Updated my #Pomodoro #PowerShell timer

Ever been so busy you can’t get anything done? What do I do during those times? Spend time optimizing my productivity routine of course. June 2020 was super busy period for me and I found that my PowerShell Pomodoro timer needed some tuning to be easier to use. Download the updated script from GitHub. I have done the following changes

  • Hide Badges on taskbar buttons
  • Create a shortcut to start it in a fast and simple way
  • Fixed so that presentationsettings.exe works in 64bit PowerShell
  • Read my original post about this script
  • Pomodoro is a technique to induce flow in a busy workday through single tasking. Read more at the end of this blogpost

Hide badges on taskbar buttons

Instead of stopping Microsoft Teams, I hide the badges on taskbar buttons such as Outlook, Teams and Microsoft To Do. You must have access to changing the registry for this to work which was the best approach I could find.

#Hide badge or stop Teams
if ($Teamsmode -notmatch "HideBadge"){
    #Stop Microsoft Teams
    Write-Host "Closing Microsoft Teams" -ForegroundColor Green
    Get-Process -Name Teams -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue
}
else{
    #Hiding badges on taskbar buttons such as Outlook, Teams and ToDo
    Write-Host "Hiding badges on taskbar buttons" -ForegroundColor Green
    Set-Itemproperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'TaskbarBadges' -value '0'
    Stop-Process -ProcessName explorer
}

During hide badge you will not see status in the taskbar icons, which helps you keep focus during the Pomodoro sprint.

When the Pomodoro sprint is finished, it will show badges again

Showing badge on taskbar app is new in Microsoft To Do and can be turned on or off under settings, I prefer to turn it off

Create a shortcut to start it in a fast and simple way

In order to start the script in an fast and simple way, you can create a shortcut to the script.

  1. On you desktop, right click and select new shortcut
  2. In the shortcut target box, type the following:
    • powershell.exe -noexit -ExecutionPolicy Bypass -File
  3. File is the path where you stored the Start-SimplePomodoro.ps1
    • “C:\Users\UserName\OneDrive – CloudWay\Dokumenter\GitHub\MyScripts\Start-SimplePomodoro\Start-MySimplePomodoro.ps1”
  4. I have crated an Icon you can use for the shortcut which you can find on GitHub
  5. If you pin it to you taskbar, you can easily start your Pomodoro sprint

Fixed so that presentationsettings.exe works in 64bit PowerShell

I use presentationsettings.exe to put the computer in presentation mode which supresses popups from all you applications and Windows 10. This is an 32bit application. I found that 64bit PowerShell could not find this due to the feature, File System Redirector. I found a workaround and incorporated it in the script so that it works wherever you are running it

Write-Host "Starting presentation mode" -ForegroundColor Green
if (Test-Path "C:\Windows\sysnative\PresentationSettings.exe"){Start-Process "C:\Windows\sysnative\PresentationSettings.exe" /start -NoNewWindow}
else {presentationsettings /start}

By pointing 64bit PowerShell to the path C:\Windows\sysnative\ I was able to run 32bit apps like PresentationSettings.

The result

Download the script from GitHub

The goal is to induce the flow state in a busy workday

Multitasking is a myth. The goal is to reach the flow state by focusing on one task at a time. Have you ever started writing an email, thought you sent it and eagerly waiting for a response, only to find it incomplete and unsent at the end of the day? This is one of the perils of multitasking.

The Pomodoro Technique is a great methodology to induce flow in a busy workday. It is all about avoiding distractions for 15-25 minutes and focus on one task at a time. This is a short enough period in the day that you can squeeze it in before a meeting. It is incredible what you can get done 15-25 minutes. The goal is to not get distracted and it takes about 7 minutes of focus before you reach your flow state.

If you want to succeed with Pomodoro, you need to make yourself unavailable. Equally important, you need to make yourself available again when those 25 minutes have passed. That is why we created the Pomodoro PowerShell tool, and why I love the simplicity of this approach.

Watch an outtake from my session at Microsoft Ignite 2017 on single-tasking

Learn more on my thinking around single-tasking and tools available to succeed with the flow state, from this outtake of my OneNote LifeHacks talk at Microsoft Ignite 2017

Happy deep work!

My current #PowerShell #Pomodoro timer

I have long been a fan of and have the need for tools to reach flow state and deep work. Through my OneNote LifeHacks videos and previous tools and posts, I have shared this.

Since Microsoft Teams arrived, I have had some issues adjusting and it has taken some time. But now I have incorporated Teams in my PowerShell Pomodoro timer, by simply closing it during my focus session and open it again. I found that even if I used the newly implemented focus time in Teams, I still saw the number of unread notifications in the client. This was disturbing enough to bring me out of flow.

Read about the updates I recently made to this script

Here is what the PowerShell Pomodoro timer doesStart-SimplePomodoroGet it at GitHub, got a suggestion? Make a commit :)

What you need to set up to use the script

  • If you have a workstation, you need to install the mobility feature on your PC to be able to set the computer in presentation mode
  • Set up IFTTT webhooks to mute your phone, I have set this up for Android, but it seems like it is possible for iOS as well now. You need a mute, unmute and webhook code.
  • Find the Uri for your focus Spotify list and use it the script
  • The script itself is just a function, you need to create your run command in the bottom of the script with your variables to run it, see details on GitHub

The goal is to induce the flow state in a busy workday

Multitasking is a myth. The goal is to reach the flow state by focusing on one task at a time. Have you ever started writing an email, thought you sent it and eagerly waiting for a response, only to find it incomplete and unsent at the end of the day? This is one of the perils of multitasking.

The Pomodoro Technique is a great methodology to induce flow in a busy workday. It is all about avoiding distractions for 15-25 minutes and focus on one task at a time. This is a short enough period in the day that you can squeeze it in before a meeting. It is incredible what you can get done 15-25 minutes. The goal is to not get distracted and it takes about 7 minutes of focus before you reach your flow state.

If you want to succeed with Pomodoro, you need to make yourself unavailable. Equally important, you need to make yourself available again when those 25 minutes have passed. That is why we created the Pomodoro PowerShell tool, and why I love the simplicity of this approach.

Watch an outtake from my session at Microsoft Ignite 2017 on single-tasking

Learn more on my thinking around single-tasking and tools available to succeed with the flow state, from this outtake of my OneNote LifeHacks talk at Microsoft Ignite 2017

Happy deep work!