Building an auto deny on meeting requests in Power Automate

Now this is something completely different. I’ve never used Power Automate before and would never have thought to use it if it hadn’t been for the 101 session by Alexander Klein at datasaturday Gothenburg.

Issue

For some reason, people like to invite me to meetings. That’s OK if I can add to the fun, but I’ve decided that my lunch break is time for me. To eat, relax, take a walk and disconnect from work. You’re allowed any opinion on that, it’s my personal choice for my mental health.
When meetings are scheduled during that time, I have to reply that I’m not joining and depending on my feeling at that time, I can reply nicely, more blunt or not at all. Or, the worst one, tentative. That’s not who I want to be, so I decided that I’d like to automate the process. But how.

Data Saturday

These events are great for learning something new you’ve never done anything with. Even if after the session you decide it’s not for you, you’ll walk away with better knowledge of why.
Alexander gave a good intro into Power Automate and was open to questions during the session. When I asked him about the problem, his reply was ‘yes, it can be done’. Cool, let’s try and do it.

Logging into Power Automate

I logged into the power automate portal to see if I could build things there. As it turns out, my company has the correct licenses to do stuff there. Alexander said something about E3 and E5 licenses for Office 365, but you should check it out for yourself to see if you’ve got the correct licenses.
On the left you see a number of options, I went to Create.

Time to create new cool stuff

Next, I chose to create an automated cloud flow

Automate all the things 😉

Connect to Outlook

Look at all the Outlook options!

I thought this would be difficult with MFA, but as it turned out the connection was created automatically. I just clicked on the Outlook 365 connector and the connection was created for me. Cool.

Getting the invites

You’re used to getting meeting invites in your mail, they’re called events in Power Automate. I ended up needing the ‘When an event is added, updated or deleted’, one. This one checks your outlook calendar for new events or when events are updated or deleted. That will do just fine.

You need to select the calendar events are added to. You may have just one or (a lot) more.

Filtering

Next I need some logic. If the the invite has a start time after 12 and before 13, I don’t want to participate. The logic itself isn’t really hard, take the hour part of the invite date time and when it’s equal to 12, deny it. If it’s something else, do nothing.

You can add a new step with a condition. This will help you out with filtering the events. The two conditions I built that the start-time of the event should be 10 (more on that later) and the Organiser should be from my company. Why the latter? I’d like to give clients an extra chance and I might have asked them for a meeting during lunch hours.
Now, the Organiser field is ease to read, the function for the timeslot isn’t. At least not from the screenshot. So here’s the code

int(formatDateTime(triggerOutputs()?['body/start'],'HH'))

What this does it look at the start field from the body of the event. This comes from the trigger input. The function around is the datetime format, in this case I’m extracting the hour. Because the output is a varchar, I have to convert it to an integer to allow the comparison without datatype issues. And as a DBA, I like my datatypes to be equal.

So what to do when it evaluates to true and false. When false, I do nothing, the invite goes in my mailbox and that’s it. When true:

Respond to a badly timed meeting

If the event matches, I send a reply gracefully declining the invite. As I’m still working on a more than good enough reply, I’ve hidden the content. I’m confident you are able to create your own. Remember to create a friendly reply.

Failed

My first test failed. It failed for the simple reason that when Outlook receives an invitation, it’s not in my time-zone but in the GMT one it seems. So I had to change my 12 to 10 (as I’m in the GMT + 2 time-zone now with the daylight savings) and test it again. And, it worked! I do wonder what happens when we change the daylight savings in October, something to test then,.

Only co-workers

Now, I don’t want to block out clients by default. Depending on the client I might want to accept the meeting and lunch earlier or later, so these have to pass without any automation. So I added a filter that a meeting request has to have an organiser from my company. I’m taking the last part of the email address as that identifier.

Job done.

Thank you so much for the inspiration Alexander and it goes to show again what a data saturday is capable of. Wherever you go, you can ALWAYS learn something new and interesting.

Thanks for reading!

Leave a comment