# How do I invoke a Copilot Studio agent from a Power Apps code app?

Exam: AB-400 — Power Platform Developer Associate
Knowledge domain: Extend the user experience (25–30%)
Updated: 2026-11-25T06:47:19.164025+00:00
HTML: https://learningpathx.com/faq/AB-400/ab400-power-apps-code-app-copilot-studio-agent.html

## Also asked as

- How can I connect a published Copilot Studio agent and wait for its response in a code app?
- How do I use a Copilot Studio response as a draft inside a Power Apps code app?

Add an approved Microsoft Copilot Studio connection to the code app and call the generated `ExecuteCopilotAsyncV2` operation for a published agent. This is the documented **Execute Agent and wait** operation, which returns responses synchronously.

In the initialized project, use `pa connection list` to find the intended connection and add it with `pa app add data-source --connector "shared_microsoftcopilotstudio" --connection-id <connectionId>`. Inspect the generated service. Pass the permitted `message`, the case-sensitive `agentName` from the published agent's Web app channel connection details, and the documented `notificationUrl` placeholder `https://notificationurlplaceholder`. This synchronous mode requires the placeholder as an input and returns through the operation response.

Read completion and response data through the generated contract, including its conversation identifier when relevant. Show suggested text as a draft for review. Validate structured data before using it and keep data saves and workflow calls behind their own authorized user actions. Test malformed, empty and incomplete responses after checking the correct tenant, agent publication and connection.

[Connect Power Apps code apps to Copilot Studio](https://learn.microsoft.com/en-us/power-apps/developer/code-apps/how-to/connect-to-copilot-studio)

Source: [AB-400: Building Code Apps with Dataverse and Automation](https://learningpathx.com/news/ab-400-building-code-apps-with-dataverse-and-automation.html)
