Set Do not Disturb in Microsoft Teams

Now set yourself to Do Not Disturb in Teams in Power Automate in 2 steps

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.

Do not Disturb 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 1

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 2

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 3

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 4

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 5

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.

Leave a Reply

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

%d bloggers like this: