Copilot Agent Inventory Sync
Scheduled flow calls the Power Platform Admin API via HTTP to enumerate all Copilot Studio agents across environments. Upserts each agent record into a Dataverse governance table tracking agent name, environment, owner, last modified date, and published status. Foundation for AI governance dashboards.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
A scheduled governance flow that calls the Power Platform Admin API via HTTP to enumerate all Copilot Studio agents in a target environment, then upserts each agent record into a Dataverse governance table. Tracks agent name, environment, owner, last modified date, and published status. Foundation for AI governance dashboards in Power BI.
Use Case
Power Platform / AI governance teams need a recurring inventory of Copilot Studio agents to spot abandoned agents, unpublished drafts, and ownership drift. This flow provides a weekly sync from the Power Platform Admin API into a structured Dataverse table, enabling trend analysis, compliance reporting, and lifecycle management via Power BI dashboards or downstream automation.
Flow Architecture
Recurrence Weekly Monday 8AM UTC
RecurrenceRuns weekly on Mondays at 08:00 UTC.
Initialize Variables (8 parallel)
Initialize variableEight parallel Initialize Variable actions: six env var binds (varTenantId, varClientId, varClientSecret, varTargetEnvironment, varAdminEmail, varAgentTable) plus two working vars (varSyncTimestamp as string utcNow(), varNewAgentCount as integer 0).
Get Copilot Agents
HTTPGET https://api.powerplatform.com/appmanagement/environments/{varTargetEnvironment}/chatBots?api-version=2022-03-01-preview using ActiveDirectoryOAuth (audience: https://api.powerplatform.com).
Parse Agent List
Parse JSONParses the HTTP response with a schema exposing the value[] array containing botId, displayName, environmentName, ownerDisplayName, lastModifiedDate, and publishedStatus for each agent.
For Each Agent
Apply to eachFor each agent in body('Parse_Agent_List')?['value']: queries Dataverse for an existing record, then branches on the If condition to update or create the agent record.
Query Existing Agent
List rows (Dataverse)Lists rows from flowlibs_copilotagentinventorys filtered by flowlibs_agentid eq '{botId}' to determine whether the agent already exists.
Check If Agent Exists
If conditionEvaluates length(outputs('Query_Existing_Agent')?['body/value']) > 0 to decide whether to update an existing record or create a new one.
- Update Agent Record — Updates name, environment, owner, lastModifiedDate, and publishedStatus on the existing flowlibs_copilotagentinventory record.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_GraphTenantId | String | <your-tenant-id> | Azure AD tenant ID used by the HTTP action's ActiveDirectoryOAuth authentication. |
| flowlibs_GraphClientId | String | <configure> | App registration (client) ID for the HTTP OAuth call to the Power Platform Admin API. |
| flowlibs_GraphClientSecret | String | <configure> | App registration client secret paired with the client ID for HTTP OAuth. Store in a secure secret store where possible. |
| flowlibs_TargetEnvironmentName | String | <configure> | Power Platform environment ID (GUID) to scan for Copilot Studio agents. |
| flowlibs_AdminNotificationEmail | String | alerts@yourcompany.com | Admin email kept for reference and available for downstream notification extensions. |
| flowlibs_CopilotAgentTableName | String | flowlibs_copilotagentinventorys | Dataverse entity set (plural) name for the agent inventory table queried/updated by the flow. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Microsoft Dataverse | shared_commondataserviceforapps | ListRecords (Query Existing Agent) UpdateRecord (Update Agent Record (true branch)) CreateRecord (Create Agent Record (false branch)) |
| HTTP (built-in) | http | HTTP (GET Copilot agents via Power Platform Admin API with ActiveDirectoryOAuth) |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Configure OAuth credentials
- Register an app in Azure AD with the https://api.powerplatform.com/.default permission, then set flowlibs_GraphTenantId, flowlibs_GraphClientId, and flowlibs_GraphClientSecret current values to match.
- Set target environment
- Update flowlibs_TargetEnvironmentName to the environment ID you want to scan (e.g., the default environment GUID for your tenant).
- Multi-environment scanning
- Wrap the HTTP call and Foreach in an outer loop that iterates environments returned by GET https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments?api-version=2023-06-01.
- Add notification
- Extend with an Outlook SendEmailV2 or Teams PostMessageToConversation action after the Foreach to email or post a sync summary when varNewAgentCount > 0.
- Power BI dashboard
- Point a Power BI DirectQuery or Import dataset at the flowlibs_copilotagentinventory Dataverse table to visualize agent count over time, ownership distribution, and stale-agent trends.
- Change cadence
- Edit the Recurrence trigger to Day / Hour for tighter cadences, or Month for monthly governance reviews.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Get Copilot Agents URI
Builds the Power Platform Admin API URL for the target environment.
EXPR.02Query Existing Agent filter
OData filter passed to the Dataverse List rows action to find an existing inventory row for this agent.
EXPR.03Check If Agent Exists condition
Branch criterion: true if the agent already has a Dataverse row, false if it is new.
EXPR.04Update Agent — record ID
Extracts the primary key of the existing inventory row for the Update Record action.
EXPR.05Null-safe field mapping
Falls back to 'Unknown' when the Copilot agent has no owner display name.
EXPR.06Compose Sync Summary
Final summary text built from the sync timestamp and new-agent counter.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.