Clean up stale Entra B2B guest accounts with Microsoft Graph, Teams, and SharePoint
Ready for 3.0What this workflow does
This workflow has 24 nodes and runs on a schedule (cron 0 8 * * 1). Along the way it connects Microsoft Teams.
How it runs
Trigger: On a schedule (cron 0 8 * * 1).
- Set Config Parameters (Edit Fields (Set)): sets 8 fields: sharepointSiteId, sharepointListId, teamsTeamId…
- Initialize Pagination Loop (Code): runs custom JavaScript code
- Fetch Guest Page via URL (HTTP Request): calls an HTTP API
- Accumulate Guests from Page (Code): runs custom JavaScript code
- If: checks a condition and branches into true / false
- Set Next URL (Edit Fields (Set)): sets 1 field: nextUrl
- Filter Stale Guest Accounts (Code): runs custom JavaScript code
- Check Stale Guests Presence (If): checks a condition and branches into true / false
- Unpack Stale Guests Array (Code): runs custom JavaScript code
- Notify No Stale Guests (Microsoft Teams): work with channel message
…plus 11 more steps. See the full node list below.
Services it uses
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
Nodes used (10)
- Schedule Trigger
n8n-nodes-base.scheduleTrigger - Edit Fields (Set)
n8n-nodes-base.set - Code
n8n-nodes-base.code - HTTP Request
n8n-nodes-base.httpRequest - If
n8n-nodes-base.if - Microsoft Teams
n8n-nodes-base.microsoftTeams - Loop Over Items (Split in Batches)
n8n-nodes-base.splitInBatches - Wait
n8n-nodes-base.wait - Merge
n8n-nodes-base.merge - No Operation, do nothing
n8n-nodes-base.noOp
From the author
Quick overview This workflow runs weekly to find inactive Entra ID (Azure AD) B2B guest accounts using Microsoft Graph sign-in activity, notifies each guest’s sponsor via Microsoft Teams, waits 72 hours, deletes the accounts, and logs successful deletions to…