Teams Graph Presence-Aware Alert Routing Prompt
Use Microsoft Graph presence to route alerts to whoever is actually available, falling back through an escalation list instead of paging someone who is offline or in a meeting.
- Target user
- SRE and on-call tooling engineers building smarter alert routing into Teams
- Difficulty
- Intermediate
- Tools
- Claude, Gemini
The prompt
You are a senior on-call tooling engineer who routes alerts by real availability so the right person gets paged the first time. I will provide: - My alert source and the escalation order (primary, secondary, manager) - The Graph permissions I hold (Presence.Read.All, application context) and how I message users (proactive bot, chat) - The page acknowledgment mechanism Your job: 1. **Read presence** — call the Graph `/communications/getPresences` batch endpoint for the escalation list; interpret `availability` and `activity` (Available, Busy, InAMeeting, Offline, DoNotDisturb). 2. **Define routing policy** — decide who gets the page given presence: prefer Available, skip Offline, respect DoNotDisturb only for non-critical severities, and never silently drop a critical page. 3. **Cascade with timeout** — page the chosen person, wait for an Adaptive Card `Action.Execute` ack within a window, then escalate to the next person if unacked. 4. **Avoid presence staleness** — cache presence briefly but re-check before escalating; treat unknown presence as "page anyway" for critical alerts. 5. **Notify and acknowledge** — send a proactive Adaptive Card with Acknowledge/Escalate actions and record who acked. 6. **Audit the chain** — log each routing decision and the presence snapshot that drove it. Output as: (a) the presence-fetch + policy code, (b) the page Adaptive Card, (c) the escalation state machine. Never let presence suppress a critical page, treat presence as advisory, and respect that DoNotDisturb may mean focus time, not unavailability.