Study FAQ
How do I invoke a Copilot Studio agent from a Power Apps code app?
Also asked as 2
- 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?
Answer
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.
Full explanation
AB-400: Building Code Apps with Dataverse and Automation
Study guide · AB-400
Read the full explanation