Set Do not Disturb status in Microsoft TeamsSet Do not Disturb status in Microsoft Teams

Have you tried to set yourself to Do Not Disturb (DND) in Power Automate?

Do Not Disturb in Teams

In Teams you can set yourself to Do Not Disturb by selecting the Do not disturb option in Microsoft Teams. You simply click on your photo click on the little arrow next to Available and the status menu will appear.

Set Do not Disturb status in Microsoft Teams
Set Do not Disturb status in Microsoft Teams

But what if you want to automate this?

Power Automate and DND

At first I was hoping for an API in Microsoft Teams. But the Microsoft Teams connector in Power Automate or any of the available APIs don’t allow me to set the status to DND. You would hope for Microsoft Graph to help, but it doesn’t offer the option that I need.

Then I looked at various PowerShell options, but still no luck. DND seems to be a special kind of Busy status and then you look at the data you always get busy reported rather than DND. It also seems to not be possible to set the status to DND.

Then I looked at using Focus Time. Somehow Focus time does set the status to DND. This seems to be to only option that I can possible use to get to a working solution.

Focus Time and Do not disturb.

In MyAnalytics, I can let My Analytics to create Focus time items. These focus time items set my focus time and my status in Teams to DND.

Now set yourself to Do Not Disturb in Teams in Power Automate in 2 steps Microsoft Office 365, Microsoft Power Automate, Microsoft Teams image 15

Ok, this is good, but I will end up with about 10 of these focus time blocks.

For the solution to work I’m renaming one of these blocks to give it a unique name. It doesn’t really matter what you call it. If you want to you could even call it “Do not delete!”

Now set yourself to Do Not Disturb in Teams in Power Automate in 2 steps Microsoft Office 365, Microsoft Power Automate, Microsoft Teams set do not disturb in microsoft teams

Now I have one focus time item in my calendar with a unique name. This unique name I will use later to find the item in my Power Automate flow.

Initially I was thinking about copying these items, but somehow it isn’t possible to copy these items automatically. Manually copying them in Outlook does work, but that isn’t what I want!

Requirements

My client is a school that wants to help teachers by setting their status to DND. So this means that somewhere I can collect the scheduling data for all the teachers.

The scheduling data can then be used to set the status in Microsoft Teams. All I will need is who and when.

The earlier created focus time DND template event in my calendar is going to travel with people. So rather than filling the calendars with many Focus time events, I’m going to create one focus time event that moves around.

On a regular basis I now only need to check if the event needs to be moved. If it does need to be moved then I can do so.

Moving events in Power Automate

The first steps are to find the focus time event in my calendar. In my example below I’m using a manual trigger, but you could of could of course use other triggers. I could imagine using a scheduling trigger as you might want to run this flow on a regular basis.

Now set yourself to Do Not Disturb in Teams in Power Automate in 2 steps Microsoft Office 365, Microsoft Power Automate, Microsoft Teams image 17

Now we need to update the event with a new start and end time. i’m using the following expression for the start time

formatDateTime(utcNow(), 'yyyy-MM-ddTHH:mm:00')

And for the end time I’m using

formatDateTime(addMinutes(utcNow(), 5), 'yyyy-MM-ddTHH:mm:00')

But most likely you would collect these start and end times from your scheduling data.

Now set yourself to Do Not Disturb in Teams in Power Automate in 2 steps Microsoft Office 365, Microsoft Power Automate, Microsoft Teams image 18

Now when we run the flow, the event will be moved and my status in Microsoft Teams is set to DND.

Now set yourself to Do Not Disturb in Teams in Power Automate in 2 steps Microsoft Office 365, Microsoft Power Automate, Microsoft Teams image 19

Microsoft Graph API

As I showed in one of my recent posts about Excel templates the MS Graph api can do an awful lot. It could also update the calendar events of calendars that are shared with you or with a service account. How do do that final step I will look at later.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

4 thoughts on “Now set yourself to Do Not Disturb in Teams in Power Automate in 2 steps”
  1. Hi, this looks really useful but I cannot find anything similar to ‘Get events (V4)’ for Outlook. Do you have any ideas why?

  2. UPD: you must set “Show as” – “busy” in the “Update event (V4)” action, otherwise the event will be updated with the “Free” status and it will not work.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading