No time to manage your calendar? Let Power Automate assist your response to calendar invites using Microsoft Graph connectors

Hi there! I would like to share a solution about a scenario/challenge that I personally experienced in the past when I was a consultant.

Consultants or anyone who works with customers day to day bases may know that we spend the entire day with our customers to plan/work together on our projects.

Meetings after meetings -recurring everyday-, we almost never have time to check our e-mails. Most of us also miss the new meeting invites for the next day and never get a chance to say “I have a conflict in my calendar”.

So, we may end up having meetings conflicting in the calendar and unable to attend half of it. Sounds familiar?

What if we build a flow in Power Automate using out of the box Microsoft Graph connectors to check calendar availability, every time when there is a new calendar event received? May our flow be able to send a accept/tentative/decline response automatically according to user’s calendar status? Yes, of course it can!

Power Automate has hundreds of Microsoft Graph powered out of the box connectors to get e-mails, post messages to Teams, send a calendar invite and many more. However, not all M365 datasets are available in this collection of built-in connectors. If you are interested in using any M365 dataset in your project, Microsoft Graph Power Automate Tutorial shows how to build a custom connector and consume it in the Power Automate flow.

For this example, We have the right out of the box connectors to design the scenario. Process will be similar to the flow shown below:

Let’s build our flow in Power Automate

Go to https://flow.microsoft.com and select Create on the left hand side menu and choose Automated flow.

Give a name to your flow and choose your flow trigger as When a new event is created (V3). Select Create.

In the flow, add the following connectors and fill the fields as follows:

  • When a new event is created (V3)
  • *Calendar id: [Calendar]
  • Get Event (V3)
  • *Calendar id: Calendar
  • *Item id: [Id] (Dynamic content/When new event is created (V3))
  • Get calendar view of events (V3)
  • *Calendar id: Calendar
  • *Start time: [Start time] (Dynamic content/Get Event (V3))
  • *End time: [End time] (Dynamic content/Get Event (V3))

  • Filter array
    *From: [value] (Dynamic content/Get calendar view of events (V3))
  • *Choose a value: [Id] (Dynamic content/Get calendar view of events (V3))
  • *Filter: is not equal to
  • *Choose a value: [Id] (Dynamic content/Get Event (V3))
  • Condition
    *Choose a value: length(body(‘Filter_array’))
    (Expression)
  • *Condition: is less than or equal to
  • *Choose a value: 0

  • IF YES
  • Respond to an event invite (V2)
    *Event Id: [Id] (Dynamic content/Get Event (V3))
  • *Response: Accept
  • *Comment: Looking forward to talk to you soon!
  • *Send Response: Yes
  • Post a message as the Flow bot to a user (Preview)
  • *Recipient: { your recipient e-mail here }
  • *Message: [Subject] (Dynamic content/Get Event (V3)) organized by [Organizer] (Dynamic content/Get Event (V3)) is accepted and added in your calendar.
  • *Headline: Meeting accepted!
  • IF NO
  • Get calendar view of events (V3)
    *Calendar Id: Calendar
  • *Start Time: [End time] (Dynamic content/Get Event (V3))
  • *End Time: addDays(body(‘Get_event_(V3)’)?[‘end’],1)
    (Expression)
  • Condition
  • *Choose a value: length(body(‘Get_calendar_view_of_events_(V3)_2’)?[‘value’])
  • (Expression)
  • *Condition: is greater than or equal to
  • *Choose a value: 5
  • IF YES
  • Respond to an event invite (V2)
    *Event Id: [Id] (Dynamic content/Get Event (V3))
  • *Response: Decline
  • *Comment: Hi, unfortunately there is a conflict in my calendar. So, I won’t be able to join this meeting today. Can we meet any other day?
  • *Send Response: Yes
  • Post a message as the Flow bot to a user (Preview)
  • *Recipient: { your recipient e-mail here }
  • *Message: [Subject] (Dynamic content/Get Event (V3)) organized by [Organizer] (Dynamic content/Get Event (V3)) is declined.
  • *Headline: Meeting declined!
  • IF NO
  • Send email with options
    *To: Organizer (Dynamic content/Get Event (V3))
  • *Subject: Tentative: Can we reschedule?
  • *User Options: Yes, No
  • Post a message as the Flow bot to a user (Preview)
  • *Recipient: { your recipient e-mail here }
  • *Message: [Subject] (Dynamic content/Get Event (V3)) organized by [Organizer] (Dynamic content/Get Event (V3)) is conflicting with other meetings. We realized you have some availabilities in your calendar and asked [Organizer] (Dynamic content/Get Event (V3)) to reschedule.
  • *Headline: Reschedule requested!

Test the scenarios!

Select Save and Test on the right hand side bar and choose I’ll perform the trigger action to test your flow.

The flow is tracking the following account’s calendar: Mod Administrator (admin@M365x716122.onmicrosoft.com)
The user who sends the calendar invites: Ayca Bas (aycabas@M365x716122.onmicrosoft.com)

Scenario 1: No Conflict

Ayca Bas sends a calendar invite to the Mod Administrator. If there is no conflict in Mod Administrators’ calendar, Ayca Bas will receive an Accepted response, and Flow bot will notify Mod Administrator about the taken action.

Ayca Bas receives:

Mod Administrator receives:

Scenario 2: Conflict, calendar is not busy for the day

Ayca Bas sends a calendar invite to the Mod Administrator. If there is a conflict in Mod Administrators’ calendar but there are less than 5 events for the day, Ayca Bas will receive a Tentative response, requesting to reschedule the meeting. Flow bot will notify Mod Administrator about the taken action.

Ayca Bas receives:

Mod Administrator receives:

Scenario 3: Conflict, calendar is busy for the day

Ayca Bas sends a calendar invite to the Mod Administrator. If there is a conflict in Mod Administrators’ calendar and there are more than 5 events for the day, Ayca Bas will receive a Decline response. Flow bot will notify Mod Administrator about the taken action.

Ayca Bas receives:

Mod Administrator receives:

Solution package.zip file can be found under the following repository: My Calendar Manager.

Microsoft Graph + Power Automate = M365 data with no code!

Microsoft Graph provides a single endpoint to get connected with M365 data. We know that Power Automate has many built-in MS Graph components to access Outlook, Planner, Calendar and more. But, think about calling Microsoft Graph API with custom filters from Power Automate directly! It is even more exciting and gives us more flexibility and numerous automation possibilities with no-code. Today, our scenario is to get “members” of a particular group in 3 quick steps.


Step 1: Register an application in Azure Active Directory

  • Go to Azure Portal.
  • Under Azure Active Directory, go to App Registration and click on New Registration.
  • Give a name to your app, choose the access level and hit Register button.
  • Go to API permissions tab, click on Add a permission, select Microsoft Graph and then Application permissions, add the following permissions: “Group.Read.All”, “Group.ReadWrite.All”, “User.Read.All”, “GroupMember.ReadWrite.All”, “User.ReadWrite.All”, “Directory.ReadWrite.All”.
  • After creating the permissions, we need to grant consent to the application to allow the application to access Graph API.
  • Go to Certificates & secrets and create a new client secret and copy in a notepad.
  • Finally, go to Overview tab, copy Application (client) ID and Directory (tenant) ID to a notepad, we will need it later.

Step 2: Build Power Automate Flow

  • Go to Microsoft Power Automate Portal.
  • Click on Create tab and choose Instant flow.
  • Give a flow name and choose When an HTTP request is received as a trigger of the flow, then click Create.
  • Extend When a When an HTTP request is received block and click on Use sample payload to generate schema, then add the following schema:
{
    "type" : "object",
    "properties" : {
       "groupId" : {
          "type" : "string"
       }
     }
}
  • Then click Save.
  • Click New Step and add Initialize variable with the following details:
    • Name: application_id
    • Type: string
    • Value: AAD App – Application (Client) Id
  • Click New Step and add Initialize variable with the following details:
    • Name: directory_id
    • Type: string
    • Value: AAD App – Directory (Tenant) Id
  • Click New Step and add Initialize variable with the following details:
    • Name: secret
    • Type: string
    • Value: AAD App secret
  • Click New Step and add HTTP with the below details:

Step 3: Test the Flow with Microsoft Graph Explorer and Postman

  • Go to Microsoft Graph Explorer.
  • Sign-in with your account.
  • Find all groups under my organization under Sample queries and click on it.
  • Copy one of the group ids for the testing purposes, we will use it in.
  • You may use Postman for testing purposes, and specify the following details:
    • Method: Post
    • Endpoint: copy it from the first step of your flow (When a HTTP request is received)
    • Header:
      • Key: Content-type
      • Value: application/json
    • Body: { “groupId” : “copied-groupid-from-GraphExplorer“}
  • Run test from Power Automate and send the post request from Postman.

After the successful flow, we should receive the output with all the members’ information in Json format under HTTP block.

Cheers.

– Ayca