Microsoft.Agents.CopilotStudio.Client 0.2.154-alpha

Prefix Reserved
This is a prerelease version of Microsoft.Agents.CopilotStudio.Client.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Microsoft.Agents.CopilotStudio.Client --version 0.2.154-alpha
                    
NuGet\Install-Package Microsoft.Agents.CopilotStudio.Client -Version 0.2.154-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Agents.CopilotStudio.Client" Version="0.2.154-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Agents.CopilotStudio.Client" Version="0.2.154-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.Agents.CopilotStudio.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.Agents.CopilotStudio.Client --version 0.2.154-alpha
                    
#r "nuget: Microsoft.Agents.CopilotStudio.Client, 0.2.154-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Microsoft.Agents.CopilotStudio.Client@0.2.154-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Microsoft.Agents.CopilotStudio.Client&version=0.2.154-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Microsoft.Agents.CopilotStudio.Client&version=0.2.154-alpha&prerelease
                    
Install as a Cake Tool

Microsoft.Agents.CopilotStudio.Client

Provides a client to interact with agents built in Copilot Studio. This Library is intended to provide access to a given agent's conversational channel.

Instructions - Required Setup to use this library

Prerequisite

To use this library, you will need the following:

  1. An Agent Created in Microsoft Copilot Studio.
  2. Ability to Create a Application Identity in Azure for a Public Client/Native App Registration Or access to an existing Public Client/Native App registration with the CopilotStudio.Copilot.Invoke API Permission assigned.

Create a Agent in Copilot Studio

  1. Create or open an Agent in Copilot Studio
    1. Make sure that the Copilot is Published
    2. Goto Settings ⇒ Advanced ⇒ Metadata and copy the following values, You will need them later:
      1. Schema name - this is the 'unique name' of your agent inside this environment.
      2. Environment Id - this is the ID of the environment that contains the agent.

Create an Application Registration in Entra ID to support user authentication to Copilot Studio

This is used when you are creating an application soly for the purpose of user interactive login and will be using a client that will surface an Entra ID MultiFactor Authentication Prompt.

If you are using this client from a service, you will need to exchange the user token used to login to your service for a token for your agent hosted in copilot studio. This is called a On Behalf Of authentication token. You can find more information about this authentication flow in Entra Documentation.

This step will require permissions to Create application identities in your Azure tenant. For user authentication, you will be creating a Native Client Application Identity, which does not have secrets.

  1. Open https://portal.azure.com
  2. Navigate to Entra Id
  3. Create an new App Registration in Entra ID
    1. Provide an Name
    2. Choose "Accounts in this organization directory only"
    3. In the "Select a Platform" list, Choose "Public Client/native (mobile & desktop)
    4. In the Redirect URI url box, type in http://localhost (note: use HTTP, not HTTPS)
    5. Then click register.
  4. In your newly created application
    1. On the Overview page, Note down for use later when configuring the example application:
      1. the Application (client) ID
      2. the Directory (tenant) ID
    2. Goto Manage
    3. Goto API Permissions
    4. Click Add Permission
      1. In the side pannel that appears, Click the tab API's my organization uses
      2. Search for Power Platform API.
        1. If you do not see Power Platform API see the note at the bottom of this section.
      3. In the permissions list choose CopilotStudio and Check CopilotStudio.Copilots.Invoke
      4. Click Add Permissions
    5. (Optional) Click Grant Admin consent for copilotsdk
    6. Close Azure Portal

If you do not see Power Platform API in the list of API's your organization uses, you need to add the Power Platform API to your tenant. To do that, goto Power Platform API Authentication and follow the instructions on Step 2 to add the Power Platform Admin API to your Tenant

Add the CopilotStudio.Copilots.Invoke permissions to your Application Registration in Entra ID to support user authentication to Copilot Studio

How-to use

User Based auth flows

User based authentication flows are the only currently supported flow for this client.

Your code will need to create a User Token ( via MSAL Public Client or an OBO flow for a User access token) to call this service.

There are currently two ways to pass auth to the CopilotClient.

1. Create an HttpMessageRequest Handler that will populate the bearer token and assign it to the httpClient you create

In this case, you would create an HttpMessageRequestHandler that creates the bearer header on the http request message, In the example below, AddTokenHandler is responsible for adding the bearer header to the http request prior to the send:

// Create an http client for use by the DirectToEngine Client and add the token handler to the client.
builder.Services.AddHttpClient("mcs").ConfigurePrimaryHttpMessageHandler(
    () => new AddTokenHandler(settings));

Then create an instance the client and request to start a conversation:

var copilotClient = new CopilotClient(settings, s.GetRequiredService<IHttpClientFactory>(), logger, "mcs");
await foreach (Activity act in copilotClient.StartConversationAsync(emitStartConversationEvent:true, cancellationToken:cancellationToken))
{

}
2. Create a function that returns a user token and pass that to the constructor for the Copilot Client

In this case, the TokenService is a class is responsible for managing the token acquire flow and returning the access token via the GetToken API call on the TokenService Class.

We do not cover how to create the TokenService Class in this document. The Copilot client is looking for a function that matches the signature Func<string, Task<string>> tokenProviderFunction

var tokenService = new TokenService(settings);
var copilotClient = new CopilotClient(settings, s.GetRequiredService<IHttpClientFactory>(), tokenService.GetToken, logger, "mcs");

await foreach (Activity act in copilotClient.StartConversationAsync(emitStartConversationEvent:true, cancellationToken:cancellationToken))
{

}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Microsoft.Agents.CopilotStudio.Client:

Package Downloads
Microsoft.SemanticKernel.Agents.CopilotStudio

Defines a concrete Agent based on the Bedrock Agent Service.

Microsoft.Agents.AI.CopilotStudio

Provides Microsoft Agent Framework support for Copilot Studio.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Microsoft.Agents.CopilotStudio.Client:

Repository Stars
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
Version Downloads Last Updated
1.3.101-beta 21 10/18/2025
1.3.93-beta 106 10/16/2025
1.3.90-beta 124 10/15/2025
1.3.88-beta 163 10/8/2025
1.3.87-beta 121 10/3/2025
1.3.63-beta 168 10/1/2025
1.3.58-beta 175 9/25/2025
1.3.57-beta 159 9/24/2025
1.3.52-beta 160 9/23/2025
1.3.47-beta 159 9/20/2025
1.3.22-beta 235 9/15/2025
1.3.20-beta 72 9/13/2025
1.3.17-beta 172 9/4/2025
1.3.15-beta 157 9/3/2025
1.3.13-beta 98 8/23/2025
1.3.10-beta 121 8/22/2025
1.3.9-beta 149 8/20/2025
1.3.1-beta 138 8/19/2025
1.2.41 16,273 8/19/2025
1.2.40-beta 120 8/16/2025
1.2.36-beta 131 8/15/2025
1.2.32-beta 285 8/8/2025
1.2.29-beta 175 7/31/2025
1.2.27-beta 134 7/30/2025
1.2.21-beta 124 7/29/2025
1.2.19-beta 164 7/19/2025
1.2.17-beta 144 7/18/2025
1.2.10-beta 174 7/16/2025
1.2.3-beta 156 7/15/2025
1.2.1-beta 145 7/13/2025
1.1.151 9,194 7/15/2025
1.1.150-beta 112 7/12/2025
1.1.147-beta 139 7/11/2025
1.1.145-beta 240 7/8/2025
1.1.139-beta 230 7/4/2025
1.1.136-beta 201 7/2/2025
1.1.128-beta 214 6/26/2025
1.1.127-beta 192 6/24/2025
1.1.126-beta 171 6/21/2025
1.1.125-beta 3,104 6/13/2025
1.1.113-beta 348 6/11/2025
1.1.110-beta 150 6/6/2025
1.1.109-beta 198 6/4/2025
1.1.107-beta 22,424 5/31/2025
1.1.103-beta 210 5/29/2025
1.1.100-beta 184 5/28/2025
1.1.95-beta 134 5/24/2025
1.1.93-beta 237 5/20/2025
1.1.91-beta 159 5/17/2025
1.1.81-beta 215 5/16/2025
1.1.68-beta 273 5/15/2025
1.1.67-beta 265 5/14/2025
1.1.51-beta 255 5/13/2025
1.1.47-beta 119 5/10/2025
1.1.45-beta 154 5/9/2025
1.1.40-beta 194 5/8/2025
1.1.32-beta 169 5/7/2025
1.1.30-beta 182 5/6/2025
1.1.28-beta 177 5/4/2025
1.1.25-beta 117 5/3/2025
1.1.18-beta 146 5/2/2025
1.1.17-beta 188 5/1/2025
1.1.10-beta-g85ab16e4d9 183 4/30/2025
1.1.1-beta 211 4/24/2025
1.0.1 736 4/24/2025
0.2.361-alpha 188 4/23/2025
0.2.358-alpha 200 4/22/2025
0.2.346-alpha 143 4/19/2025
0.2.343-alpha 207 4/18/2025
0.2.339-alpha 237 4/17/2025
0.2.315-alpha 244 4/16/2025
0.2.314-alpha 135 4/12/2025
0.2.308-alpha 228 4/10/2025
0.2.295-alpha 225 4/9/2025
0.2.290-alpha 215 4/8/2025
0.2.287-alpha 134 4/5/2025
0.2.286-alpha 297 4/4/2025
0.2.282-alpha 220 4/3/2025
0.2.277-alpha 191 4/1/2025
0.2.271-alpha 138 3/29/2025
0.2.267-alpha 172 3/28/2025
0.2.257-alpha 157 3/27/2025
0.2.180-alpha 503 3/26/2025
0.2.171-alpha 162 3/21/2025
0.2.162-alpha 184 3/19/2025
0.2.154-alpha 220 3/18/2025
0.2.153-alpha 104 3/15/2025
0.2.151-alpha 154 3/14/2025
0.2.146-alpha 196 3/12/2025
0.2.141-alpha 216 3/8/2025
0.2.137-alpha 283 3/7/2025
0.1.26 344 11/18/2024