Copilot Studio Call Agent Connector
This custom connector enables synchronous calls to Microsoft Copilot Studio conversational and autonomous agents from Power Platform applications. It uses an Azure Functions backend service that converts synchronous HTTP requests to asynchronous agent calls using the Agents SDK, making it possible to call an agent from Power Apps or Power Automate and wait for the response in a single operation.
Prerequisites
- The SyncToAsyncService Function App deployed (see ../SyncToAsyncService/README.md for deployment instructions)
- Azure subscription with permissions to create App Registrations
- Power Platform CLI (
pac) installed - Power Platform environment with permissions to create custom connectors
Setup Instructions
Step 1: Clone the Repository (if not already done)
Note: If you’ve already cloned the repository while deploying the SynctoAsyncService Function App, skip to step 2 below.
- Clone the CopilotStudioSamples repository:
git clone https://github.com/microsoft/CopilotStudioSamples.git - Navigate to the connector directory:
cd CopilotStudioSamples/CallAgentConnector/Connector
Step 2: Create Azure App Registration
- Navigate to Azure Portal
- Go to Azure Active Directory > App registrations
- Click New registration
- Configure the app registration:
- Name:
Copilot Studio Call Agent Connector - Supported account types: Select based on your requirements (typically “Accounts in this organizational directory only”)
- Redirect URI: Leave blank for now (will be updated later)
- Name:
- Click Register
- Note down the following values:
- Application (client) ID
- Directory (tenant) ID
Configure API Permissions
- In your app registration, go to API permissions
- Click Add a permission
- Select APIs my organization uses
- Search for
Microsoft Power Platform - Select Delegated permissions
- Add the permission:
CopilotStudio.Copilots.Invoke - Click Add permissions
- Click Grant admin consent (if you have admin privileges)
Create Client Secret
- Go to Certificates & secrets
- Click New client secret
- Add a description and select expiry
- Click Add
- Important: Copy the secret value immediately (you won’t be able to see it again)
Step 3: Update Configuration Files
- Update
apiProperties.json:- Replace
"clientId": "YOUR_CLIENT_ID"with your Application (client) ID
- Replace
- Update
apiDefinition.json:- Replace
"host": "YOUR_FUNCTION_APP_URL"with your deployed SynctoAsyncService Function App hostname (e.g.,synctoasyncservice.azurewebsites.net)
- Replace
Step 4: Create the Custom Connector
- Open a terminal in the connector directory
- Authenticate with Power Platform:
pac auth create --environment YOUR_ENVIRONMENT_URL - Create the custom connector:
pac connector create --api-definition-file apiDefinition.json --api-properties-file apiProperties.json --environment YOUR_ENVIRONMENT_ID --icon-file icon.png
Step 5: Update Redirect URI
- Navigate to your custom connectors in Power Apps:
https://make.powerapps.com/environments/YOUR_ENVIRONMENT_ID/customconnectors - Find your “Copilot Studio CAT” connector and click on it
- Navigate to the Security tab
- Copy the Redirect URL shown in the security settings (it will look similar to:
https://global.consent.azure-apim.net/redirect/[connector-specific-id]) - Return to your Azure App Registration in the Azure Portal
- Go to Authentication
- Click Add a platform > Web
- Paste the redirect URI you copied from the Power Platform
- Click Configure
Note: The redirect URI is generated dynamically when the connector is created and will be different from the example shown in
apiProperties.json. Always use the actual URI from the Power Platform.
Step 6: Test the Connector
- Navigate to your custom connectors:
https://make.powerapps.com/environments/YOUR_ENVIRONMENT_ID/customconnectors - Find your “Copilot Studio CAT” connector
- Click on the connector and go to the Test tab
- Create a new connection:
- Sign in with your Azure AD account
- Authorize the required permissions
- Test the
callAgentoperation with sample data
Usage Example
{
"environmentId": "abc123-def456-...",
"agentIdentifier": "my-copilot-agent",
"message": "What is the weather today?",
"conversationId": "optional-conversation-id"
}
Note:
- If you don’t provide a
conversationId, a new conversation will be started with the agent. To continue an existing conversation, include theconversationIdfrom a previous response.- The
agentIdentifieris your agent’s schema name, which can be found in Copilot Studio under Settings > Advanced > Metadata.