Microsoft.Dynamics.AgentsSDK.Middleware
1.0.0
Prefix Reserved
dotnet add package Microsoft.Dynamics.AgentsSDK.Middleware --version 1.0.0
NuGet\Install-Package Microsoft.Dynamics.AgentsSDK.Middleware -Version 1.0.0
<PackageReference Include="Microsoft.Dynamics.AgentsSDK.Middleware" Version="1.0.0" />
<PackageVersion Include="Microsoft.Dynamics.AgentsSDK.Middleware" Version="1.0.0" />
<PackageReference Include="Microsoft.Dynamics.AgentsSDK.Middleware" />
paket add Microsoft.Dynamics.AgentsSDK.Middleware --version 1.0.0
#r "nuget: Microsoft.Dynamics.AgentsSDK.Middleware, 1.0.0"
#:package Microsoft.Dynamics.AgentsSDK.Middleware@1.0.0
#addin nuget:?package=Microsoft.Dynamics.AgentsSDK.Middleware&version=1.0.0
#tool nuget:?package=Microsoft.Dynamics.AgentsSDK.Middleware&version=1.0.0
Microsoft Dynamics 365 Customer Service Agents SDK Middleware
The Agents SDK Middleware provides middleware and utilities for building agents that integrate with Microsoft Dynamics 365 Customer Service Omnichannel platform using the Microsoft Agents Framework. It simplifies the process of handling Omnichannel-specific activities, extracting channel data, and managing bidirectional communication between your agent and Dynamics 365 Customer Service.
Getting started
Install the package via NuGet Package Manager:
Install-Package Microsoft.Dynamics.AgentsSDK.Middleware
Or via .NET CLI:
dotnet add package Microsoft.Dynamics.AgentsSDK.Middleware
Prerequisites
- .NET 8.0 or later
- Microsoft Agents Framework packages
- An existing agent project or a new ASP.NET Core application
Usage
Adding the Middleware invloves multiple steps
Creating the Adapter
Inherit from CloudAdapter and add middleware using Use():
public class YourCustomAdapter : CloudAdapter
{
public YourCustomAdapter(
IChannelServiceClientFactory channelServiceClientFactory,
IActivityTaskQueue activityTaskQueue,
ILogger<IAgentHttpAdapter> logger)
: base(channelServiceClientFactory, activityTaskQueue, logger)
{
// Add middleware to the pipeline
Use(new LoggingMiddleware());
}
}
Adding to Your Agent
Register in Program.cs:
var builder = WebApplication.CreateBuilder(args);
// Register the custom adapter with middleware
builder.Services.AddAgent<YourAgent, YourCustomAdapter>();
var app = builder.Build();
Using Activity Extensions
The SDK provides extension methods to easily work with Omnichannel activities:
using Microsoft.Dynamics.AgentsSDK.Middleware.Extensions;
public async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
// Check if the activity is from Omnichannel
if (turnContext.Activity.IsOmnichannel())
{
// Get channel-specific data
var tags = turnContext.Activity.GetChannelDataOrDefault<string>("tags");
var fromUserId = turnContext.Activity.GetChannelDataOrDefault<string>("fromUserId");
// Process the activity based on channel data
await turnContext.SendActivityAsync($"Received message from user: {fromUserId}", cancellationToken);
}
}
Key Components
The SDK includes the following components:
- OmnichannelMiddleware: Microsoft Agents Framework middleware for processing Omnichannel-specific activities, handling channel data extraction, activity transformation, and user identification
- ActivityExtensions: Helper methods like
IsOmnichannel()andGetChannelData<T>()for working with Omnichannel activity data - OmnichannelMiddlewareConstants: Predefined constants for channel data keys, tags, identifiers, and regex patterns
Features
- Channel Data Processing: Automatic extraction of channel-specific metadata and user identification across channels
- Activity Transformation: Bidirectional conversion between message and event activities with preservation of original channel information
- Error Handling: Graceful handling of malformed channel data with fallback mechanisms and non-blocking error processing
Additional documentation
- Omnichannel Developer Documentation - Enable Bot Context
- Microsoft Dynamics 365 Customer Service Documentation
- Microsoft Agents Framework Documentation
Feedback
For issues, questions, and feature requests:
- Refer to the official Microsoft Dynamics 365 Customer Service documentation
� Microsoft Corporation. All rights reserved.
| Product | Versions 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. |
-
net8.0
- Microsoft.Agents.Authentication.Msal (>= 1.2.41)
- Microsoft.Agents.Builder (>= 1.2.41)
- Microsoft.Agents.Connector (>= 1.2.41)
- Microsoft.Agents.Hosting.AspNetCore (>= 1.2.41)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.1)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.8.0)
- Microsoft.IdentityModel.Protocols (>= 8.8.0)
- Microsoft.IdentityModel.Tokens (>= 8.8.0)
- System.Text.Json (>= 9.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 696 | 12/2/2025 |