Skip to main content

Wyngate Solutions

Sending Calendar Invites Using Power Automate and MS Graph API

Introduction

In today’s fast-paced world, efficient collaboration is the key to success. Calendar invites are an essential tool to help us keep track of important events and meetings. Microsoft’s Power Automate, a versatile automation service, along with the Microsoft Graph API, can be a powerful combination for sending calendar invites for events that are tracked on SharePoint event. This blog post will guide you through the process of using Power Automate and MS Graph API to send calendar invites seamlessly.

Prerequisites

To follow along, you will need:

  1. A Microsoft 365 subscription
  2. Power Automate (Flow) access
  3. Basic understanding of MS Graph API and RESTful APIs

Step 1: Register your app in Azure Active Directory (AAD)

Before we can start using MS Graph API, we need to register an application in the Azure Active Directory and grant the necessary permissions. Follow these steps:

  1. Log in to the Azure portal (https://portal.azure.com) with your Microsoft account.
  2. Navigate to Azure Active Directory.
  3. Click on “App registrations” and then click on “New registration”.
  4. Enter a name for your application, select the “Accounts in this organizational directory only” option, and click “Register”.
  5. Copy the “Application (client) ID” and “Directory (tenant) ID” for later use.
  6. Go to “Certificates & secrets” and create a new client secret. Copy this secret value for later use.

Step 2: Grant API permissions

  1. In your registered app, click “API permissions” and then “Add a permission”.
  2. Select “Microsoft Graph” and then “Application permissions”.
  3. Search for “Calendars” and grant the “Calendars.ReadWrite” permission.
  4. Click “Add permissions” and then “Grant admin consent for [Your Organization]”.

Step 3: Setup Events Calendar in SharePoint List

  1. Log into your SharePoint online site.
  2. Create Calendar Event in Site Contents.
  3. Go to List Settings and add attendees column as person.
  4. Add column to store Calendar ID for tracking the Event ID returned from the MS Graph API. This can be used for updating the event.

Step 4: Create a Power Automate Flow

  1. Log in to Power Automate (https://flow.microsoft.com) with your Microsoft account.
  2. Go to My Flows and Click on New Flow dropdown and Select Automated cloud Flow.
  3. Name your flow and choose the When an item is created for SharePoint.
  4. Select the Site from the Site Address and on List or Library Name select “Enter custom value”. Enter the Calendar title name. (The calendar list does not display in the liste items so we have to manually enter it.
  5. Initialize an array variable and name it Attendees
  6. Create Apply to each action and in Select an output from previous steps – select Attendees from the trigger. This is the Attendees column from the Calendar list.
  7. In the Apply to each block, create Compose action and select Attendees Display Name from the Trigger.
  8. Create another Compose action and Select Attendees Email.
  9. Create another Compose action and enter JSON format as follows: { "emailAddress": { "address": "output from step 8", "name": "output from step 7"}, "type": "required"}
  10. Create action Append to array and add the above JSON compose to Attendees variable.
  11. Create compose action after Apply to each block and have the following JSON code. Change the highlighted items as per your Calendar fields { "subject": "@{triggerOutputs()?['body/Title']}", "body": { "contentType": "HTML", "content": "@{triggerOutputs()?['body/Description']}" }, "start": { "dateTime": "@{triggerOutputs()?['body/EventDate']}", "timeZone": "UTC" }, "end": { "dateTime": "@{triggerOutputs()?['body/EndDate']}", "timeZone": "UTC" }, "location": { "displayName": "@{triggerOutputs()?['body/Location']}" }, "attendees": @{variables('Attendees')}}
  12. Create an HTTP action and set the following Parameters –
    • Method: Select POST
    • URI: https://graph.microsoft.com/v1.0/users/email to send meeting request from/calendar/events.
    • Headers: Content-type: application/json
    • Body: The output of the Compose action from Step 11.
    • On Advanced options Authentication: Active Directory OAuth
    • Authority: Keep the default.
    • Tenant: Enter your organization’s Tenant ID that was copied in Step 1: Register your app in Azure Active Directory (AAD).
    • Audience: https://graph.microsoft.com
    • Client ID: Enter the Client ID copied in Step 1: Register your app in Azure Active Directory (AAD).
    • Credential Type: Select Secret from the dropdown.
    • Secret: Copy the Secret value from Step 6 in Step 1: Register your app in Azure Active Directory (AAD).
  13. Create an Parse JSON action and enter the values as follows –
    • Content: Output from the HTTP action defined in the previous step.
    • Schema :
      • {
      • “type”: “object”,
      • “properties”: {
      • “@@odata.context”: {
      • “type”: “string”
      • },
      • “@@odata.etag”: {
      • “type”: “string”
      • },
      • “id”: {
      • “type”: “string”
      • },
      • “createdDateTime”: {
      • “type”: “string”
      • },
      • “lastModifiedDateTime”: {
      • “type”: “string”
      • },
      • “changeKey”: {
      • “type”: “string”
      • },
      • “categories”: {
      • “type”: “array”
      • },
      • “transactionId”: {},
      • “originalStartTimeZone”: {
      • “type”: “string”
      • },
      • “originalEndTimeZone”: {
      • “type”: “string”
      • },
      • “iCalUId”: {
      • “type”: “string”
      • },
      • “reminderMinutesBeforeStart”: {
      • “type”: “integer”
      • },
      • “isReminderOn”: {
      • “type”: “boolean”
      • },
      • “hasAttachments”: {
      • “type”: “boolean”
      • },
      • “subject”: {
      • “type”: “string”
      • },
      • “bodyPreview”: {
      • “type”: “string”
      • },
      • “importance”: {
      • “type”: “string”
      • },
      • “sensitivity”: {
      • “type”: “string”
      • },
      • “isAllDay”: {
      • “type”: “boolean”
      • },
      • “isCancelled”: {
      • “type”: “boolean”
      • },
      • “isOrganizer”: {
      • “type”: “boolean”
      • },
      • “responseRequested”: {
      • “type”: “boolean”
      • },
      • “seriesMasterId”: {},
      • “showAs”: {
      • “type”: “string”
      • },
      • “type”: {
      • “type”: “string”
      • },
      • “webLink”: {
      • “type”: “string”
      • },
      • “onlineMeetingUrl”: {},
      • “isOnlineMeeting”: {
      • “type”: “boolean”
      • },
      • “onlineMeetingProvider”: {
      • “type”: “string”
      • },
      • “allowNewTimeProposals”: {
      • “type”: “boolean”
      • },
      • “occurrenceId”: {},
      • “isDraft”: {
      • “type”: “boolean”
      • },
      • “hideAttendees”: {
      • “type”: “boolean”
      • },
      • “responseStatus”: {
      • “type”: “object”,
      • “properties”: {
      • “response”: {
      • “type”: “string”
      • },
      • “time”: {
      • “type”: “string”
      • }
      • }
      • },
      • “body”: {
      • “type”: “object”,
      • “properties”: {
      • “contentType”: {
      • “type”: “string”
      • },
      • “content”: {
      • “type”: “string”
      • }
      • }
      • },
      • “start”: {
      • “type”: “object”,
      • “properties”: {
      • “dateTime”: {
      • “type”: “string”
      • },
      • “timeZone”: {
      • “type”: “string”
      • }
      • }
      • },
      • “end”: {
      • “type”: “object”,
      • “properties”: {
      • “dateTime”: {
      • “type”: “string”
      • },
      • “timeZone”: {
      • “type”: “string”
      • }
      • }
      • },
      • “location”: {
      • “type”: “object”,
      • “properties”: {
      • “displayName”: {
      • “type”: “string”
      • },
      • “locationType”: {
      • “type”: “string”
      • },
      • “uniqueId”: {
      • “type”: “string”
      • },
      • “uniqueIdType”: {
      • “type”: “string”
      • }
      • }
      • },
      • “locations”: {
      • “type”: “array”,
      • “items”: {
      • “type”: “object”,
      • “properties”: {
      • “displayName”: {
      • “type”: “string”
      • },
      • “locationType”: {
      • “type”: “string”
      • },
      • “uniqueId”: {
      • “type”: “string”
      • },
      • “uniqueIdType”: {
      • “type”: “string”
      • }
      • },
      • “required”: [
      • “displayName”,
      • “locationType”,
      • “uniqueId”,
      • “uniqueIdType”
      • ]
      • }
      • },
      • “recurrence”: {},
      • “attendees”: {
      • “type”: “array”,
      • “items”: {
      • “type”: “object”,
      • “properties”: {
      • “type”: {
      • “type”: “string”
      • },
      • “status”: {
      • “type”: “object”,
      • “properties”: {
      • “response”: {
      • “type”: “string”
      • },
      • “time”: {
      • “type”: “string”
      • }
      • }
      • },
      • “emailAddress”: {
      • “type”: “object”,
      • “properties”: {
      • “name”: {
      • “type”: “string”
      • },
      • “address”: {
      • “type”: “string”
      • }
      • }
      • }
      • },
      • “required”: [
      • “type”,
      • “status”,
      • “emailAddress”
      • ]
      • }
      • },
      • “organizer”: {
      • “type”: “object”,
      • “properties”: {
      • “emailAddress”: {
      • “type”: “object”,
      • “properties”: {
      • “name”: {
      • “type”: “string”
      • },
      • “address”: {
      • “type”: “string”
      • }
      • }
      • }
      • }
      • },
      • “onlineMeeting”: {}
      • }
      • }
  14. Create an action Update Item for SharePoint list and enter the following value –
    • Site Address: Select the site which has the Calendar list.
    • List Name: Enter the Calendar list name.
    • Id: Select the ID from the trigger.
    • Title: Select the Title column from the trigger.
    • Start Time: select the Start Time column from the trigger.
    • End Time: select the End Time column from the trigger.
    • CalendarID: This column was added to store the Calendar id to store the ID that is returned from MS Graph API. Select the id from the Parse JSON action from the previous step.

In this blog post, we explored a comprehensive guide to creating calendar events using Microsoft Graph API and Power Automate. The process involves registering an app in Azure Active Directory, granting the necessary API permissions, and creating a Power Automate flow to send calendar invites based on SharePoint list. By leveraging the power of MS Graph API and the automation capabilities of Power Automate, users can efficiently get calendar invites to facilitate collaboration and streamline their workflow. This combination of technologies not only simplifies the event creation process but also enhances the overall event management experience for organizations using Microsoft 365.

a person writing on a desk calendar