Sunday, 1 March 2026

Build a Custom UI for a Copilot Studio Agent using the Microsoft 365 Agents SDK

Copilot Studio gives you a great “out-of-the-box” chat experience in Teams and Microsoft 365 Copilot. But sometimes you need your own UI: your branding, your layout, your telemetry, and your app’s context. So in this post, let’s wire a Copilot Studio agent into a .NET console “custom UI” using the Microsoft 365 Agents SDK client library. This will help you get started when you want to surface Copilot Studio Agents in your own custom UIs.

Scope note: This is for calling a Copilot Studio agent from your own app UI (not the iframe embed).


On a high level, we’ll:

  • Publish a Copilot Studio agent and copy its Microsoft 365 Agents SDK connection string.

  • Create an Entra app registration with the CopilotStudio.Copilots.Invoke delegated permission.

  • Use MSAL to sign in a user and get a token for the Power Platform API audience.

  • Call the agent from a lightweight console “chat UI” using Microsoft.Agents.CopilotStudio.Client.


Prereqs

  • A published Copilot Studio agent (and access to its settings).

  • .NET SDK installed (any modern LTS is fine).

  • Entra ID permission to create an app registration


1) Publish Your Agent And Copy The Agents SDK Connection String


In Copilot Studio:

  • Open your agent

  • Go to ChannelsWeb app (or Native app)

  • Under Microsoft 365 Agents SDK, copy the connection string.


Note: If your agent uses “Authenticate with Microsoft” or “Authenticate manually”, you’ll see the connection string option (and not the iframe embed code). 

2) Create An Entra App Registration For User Interactive Sign-In

In Azure portal:

  • Microsoft Entra IDApp registrationsNew registration

  • Platform: Public client/native (mobile & desktop)

  • Redirect URI: http://localhost (HTTP, not HTTPS)

Then add the delegated permission:

  • API permissionsAdd a permission

  • APIs my organization uses → search Power Platform API

  • Delegated permissionsCopilotStudioCopilotStudio.Copilots.Invoke


3) Create The “Custom UI” (A Console Chat)

This is the bare minimum idea:

  • sign in the user (MSAL)

  • get a token scoped to the Power Platform API audience (the SDK computes this for you)

  • start a conversation

  • send messages and stream responses back as activities 

Change these values:

  • directConnectUrl = copied from Copilot Studio channel page (Microsoft 365 Agents SDK section).

  • tenantId, clientId = from your Entra app registration.

Minimal Working Example

Create and run:


Troubleshooting

  • 401/403: confirm delegated permission CopilotStudio.Copilots.Invoke is granted (and admin consent if your tenant requires it). 

  • Redirect URI mismatch: make sure the app registration has http://localhost for public client. (The sample uses localhost.) 

  • No response text: Copilot Studio responses arrive as a stream of activities—log the full activity payload if you suspect you’re filtering out the wrong activity types.

  • Power Platform API missing in permissions picker: follow the sample guidance and tenant configuration notes in the repo.

Notes

  • The console app is a clean “backend harness” you can keep as-is, then wrap with an HTTP API for your React front-end to call.

  • If you need quick embed-only experiences, the iframe approach is simpler, but it’s not the same as a true custom UI.

Wrapping up

This pattern keeps your agent authored in Copilot Studio, while your product team owns the end-user experience in a custom UI. The key pieces are: connection info from Copilot Studio, Entra delegated permission, MSAL sign-in, then stream activities through the SDK client.

Hope this helps!