Skip to content

Conversation

@sw-joelmut
Copy link
Collaborator

This PR depends on #143

Description

This PR adds a Teams sample capable of capturing incoming headers to later be propagated to outgoing requests based on the HeaderPropagationAttribute configured in the Extensions.Teams project.

Specific Changes

  • Added HeaderPropagation sample under samples/Teams folder.

Testing

The following image shows the sample working and the chosen headers being propagated to the MS Teams service.
image

@sw-joelmut sw-joelmut requested a review from tracyboehrer May 14, 2025 15:00
@sw-joelmut sw-joelmut requested a review from a team as a code owner May 14, 2025 15:00
@github-actions github-actions bot added Build: Automation Tags changes to Build Automation area ML: Samples Tags changes to samples ML: Core Tags changes to core libraries ML: Tests Tags changes to tests labels May 14, 2025
@sw-joelmut sw-joelmut marked this pull request as draft May 14, 2025 15:08
@sw-joelmut sw-joelmut marked this pull request as ready for review May 14, 2025 15:14
@github-actions github-actions bot removed Build: Automation Tags changes to Build Automation area ML: Core Tags changes to core libraries ML: Tests Tags changes to tests labels May 14, 2025
@MattB-msft MattB-msft requested a review from Copilot May 16, 2025 02:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a sample project that demonstrates how to capture incoming request headers in a Microsoft Teams bot and propagate them to outgoing requests using the HeaderPropagation feature.

  • Added configuration and documentation files (appsettings.json and README.md) to support header propagation.
  • Implemented sample code in Program.cs, MyAgent.cs, and related extension methods and manifest to enable the new functionality.
  • Updated the solution file to include the new sample project.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/samples/Teams/HeaderPropagation/appsettings.json New configuration file with header propagation settings.
src/samples/Teams/HeaderPropagation/README.md Documentation detailing sample setup and usage.
src/samples/Teams/HeaderPropagation/Program.cs Sample application demonstrating middleware and agent registration.
src/samples/Teams/HeaderPropagation/MyAgent.cs Implementation of the custom agent with Teams header extension.
src/samples/Teams/HeaderPropagation/HeaderPropagation.csproj Project file for the new sample.
src/samples/Teams/HeaderPropagation/ConversationStateExtensions.cs Extension methods for managing conversation state.
src/samples/Teams/HeaderPropagation/AppManifest/manifest.json Teams manifest file for bot configuration.
src/Microsoft.Agents.SDK.sln Updated solution file to integrate the new sample.

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Agents.Builder.State;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear what is going on here, Why do you need this?

@MattB-msft
Copy link
Member

@sw-joelmut Im not clear on why we need this sample, or why it is using the teams extensions.

All that is being show here is to asp.net's built into Header Propagation features.

Somone requesting this can be pointed to use: https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.builder.headerpropagationapplicationbuilderextensions.useheaderpropagation?view=aspnetcore-9.0

Could you clarify why we should have a specific sample highlighting an asp.net feature?

@sw-joelmut
Copy link
Collaborator Author

Hi @MattB-msft,

The header propagation feature this sample illustrates is the one we are introducing in PR #143.
Using the builtin AspNet HeaderPropagation is not enough to cover async processing cases (QueueActivity in the HostedService).

As for the ConversationStateExtension, we wanted to have a Teams bot to show how to configure headers to be propagated inside the teams extension. The ConversationStateExtension was added as part of the Teams' edit event feature.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tracyboehrer
Copy link
Member

I suspect we don't need this sample. However, we need to get with Teams to discover what headers they want carried over, and the User-Agent addition they want. They used "teamsai-dotnet/x.x.x" in Teams AI, but probably not what we want for the extension. Which raises the question... Can multiple instances of [HeaderPropagation] append User-Agent values?

Unit tests can perform what this sample is doing?

@sw-joelmut
Copy link
Collaborator Author

Hi @tracyboehrer,

Unit tests can perform what this sample is doing?
We'll close this PR, and we'll try to show the different header propagation actions (Add, Append, Override, Propagate) in unit tests.

Can multiple instances of [HeaderPropagation] append User-Agent values?
Yes, we'll add a unit test to show this case.

@sw-joelmut sw-joelmut closed this May 28, 2025
@tracyboehrer tracyboehrer deleted the southworks/add/teams-header-propagation-sample branch July 8, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ML: Samples Tags changes to samples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants