Enabling Real Time Alerts using Microsoft Graph in Power Platform – Part 2

In this section of the blog series, we’ll walk through the steps to create a Microsoft Graph subscription for Teams presence updates based on the Custom connector created on the previous post and configure a Power Automate flow to receive and process these updates through Azure Event Hub.

Step 1: Creating a Microsoft Graph Subscription for Teams Presence

Microsoft Graph allows subscription to presence changes via the /communications/presences/{userId} endpoint. Subscriptions require:

  • An access token with the right scopes (Presence.Read.All)
  • A valid Event Hub endpoint as the notificationUrl
  • Expiry time (up to 1 hour for presence)
  • Resource path and change type

Tip: Presence subscriptions must be renewed every hour. This can be handled through a scheduled Power Automate flow or a timer-based Azure Function.

Step 2: Receiving Notifications via Azure Event Hub

Azure Event Hub serves as a high-throughput ingestion pipeline for Microsoft Graph notifications. After the subscription is created, presence change events are pushed into the specified Event Hub.

Each event includes metadata about the subscription, user, and timestamp, allowing you to react to presence changes in near real-time.

Step 3: Creating a Power Automate Flow to Process Presence Updates

Now that presence updates are routed into Azure Event Hub, we’ll use Power Automate to process these updates.

Steps to Configure:

  1. Trigger:
    • Use the “When events are received in Event Hub” trigger (premium connector).
    • Configure it with your Event Hub connection and consumer group.
  2. Parse Event Data:
    • Use a Parse JSON action to extract userId, subscriptionId, and changeType from the incoming event schema.
    • Optionally log the data to Azure Table, Dataverse, or send a Teams notification.
  3. Act on Status Change:
    • Add conditionals or switch-case to handle specific presence states (Available, Busy, Away, etc.).
    • Trigger actions such as updating a SharePoint list, posting an alert to Teams, or changing a device state (e.g., Hue lights for status indication).

Example Use Case:

IF presence = ‘Busy’

   → Post “User is busy now” in Teams channel

What’s Next?

In the next part of this blog series, we will:

  • Automate the renewal of presence subscriptions using a custom connector
  • Add error handling and retry logic
  • Secure the solution with Azure AD app registration and fine-tuned API permissions

Do you like this article?

Subscribe to my blog with your email address using the widget on the right side or on the bottom of this page to have new articles sent directly to your inbox the moment I publish them.

Original Post https://ashiqf.com/2025/04/30/enabling-real-time-alerts-using-microsoft-graph-in-power-platform-part-2/

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
April 2025
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30     
« Mar   May »
Follow
Sign In/Sign Up Sidebar Search
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...