Skip to content

Initial core bot activity library, CI, and extensibility#227

Draft
rido-min wants to merge 92 commits intomainfrom
next/core
Draft

Initial core bot activity library, CI, and extensibility#227
rido-min wants to merge 92 commits intomainfrom
next/core

Conversation

@rido-min
Copy link
Member

This pull request introduces the foundational structure for the new Microsoft.Bot.Core library, establishing core activity and schema types, build configuration, and initial unit tests. The changes set up the basic serialization/deserialization logic for bot activities, extensibility for custom properties, and the CI workflow for automated builds and tests.

Core Library and Schema Implementation:

  • Added the initial implementation of the CoreActivity class and supporting schema types (ActivityTypes, ChannelData, Conversation, ConversationAccount, and extensibility for additional properties) in the Microsoft.Bot.Core.Schema namespace, including JSON serialization/deserialization logic and reply creation methods. [1] [2] [3] [4] [5]
  • Introduced a placeholder for AddBotApplication in Hosting for future extensibility.

Build and Solution Configuration:

  • Added core.slnx solution file referencing the main project, unit test project, and solution items for centralized configuration.
  • Established common build properties and targets in Directory.Build.props and Directory.Build.targets, including code analysis, documentation, and versioning with Nerdbank.GitVersioning. [1] [2]
  • Configured the main project (Microsoft.Bot.Core.csproj) to target both .NET 8 and .NET 10, with appropriate package references for authentication and identity.

Continuous Integration:

  • Introduced a GitHub Actions workflow (core-ci.yaml) for building and testing the core library on push and pull requests to the next/core branch.

Unit Testing:

  • Added a unit test project (Microsoft.Bot.Core.UnitTests) with dependencies on xUnit and coverlet for code coverage, and a test suite validating extensibility and serialization/deserialization of custom activity types. [1] [2]Add .NET solution for extensible bot activity schemas with modern serialization, extension data, and reply support. Includes CI workflow, semantic versioning, and comprehensive unit tests for schema evolution and custom fields.

Add .NET solution for extensible bot activity schemas with modern serialization, extension data, and reply support. Includes CI workflow, semantic versioning, and comprehensive unit tests for schema evolution and custom fields.
Added a permissions section to the Core-CI workflow, granting read access to repository contents and write access to pull-requests. This explicitly defines the workflow's required permissions.
/// </summary>
public static readonly JsonSerializerOptions DefaultJsonOptions = new()
{
WriteIndented = true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Putting this at the bottom most layer means that more space will be used up in the payload

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, but not too much. I think it's ok for now

/// The reply activity automatically swaps the From and Recipient accounts and preserves
/// the conversation context, channel ID, and service URL from the original activity.
/// </remarks>
public CoreActivity CreateReplyActivity(string text = "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding a note: Should this exist here or be in the client layer?

Copy link
Member Author

Choose a reason for hiding this comment

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

added a new optional param to set the type

rido-min and others added 2 commits December 10, 2025 15:00
This pull request introduces several new sample bots and supporting
infrastructure to the `core` directory, demonstrating different usage
scenarios for the Microsoft.Bot.Core SDK. It also adds compatibility
support for legacy Bot Framework bots, improves development environment
configuration, and updates documentation and gitignore settings.

**New sample bots and scenarios:**

- Added three new sample projects:
-
[`CompatBot`](diffhunk://#diff-22411d9bef78e3d139f1e4b1a4d5e047bb26428a97bf59df7f5b983e584babd8R1-R13):
Demonstrates running a legacy Bot Framework bot using the new
compatibility layer, including `EchoBot` implementation and required
configuration files.
[[1]](diffhunk://#diff-22411d9bef78e3d139f1e4b1a4d5e047bb26428a97bf59df7f5b983e584babd8R1-R13)
[[2]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aR1-R35)
[[3]](diffhunk://#diff-62be1f70aaabb519334fe39cd50c0e25a98717ebb9fab85b688832917c9c75bbR1-R29)
[[4]](diffhunk://#diff-834a6cbae004839d32944b2f2a3cf8edc3a32f558597d464401178fa95781edcR1-R9)
-
[`CoreBot`](diffhunk://#diff-1087baf076a83b00d0c97ef01c02174668cb26c9fad5d2c33284e0889150ed65R1-R13):
Shows a simple bot using the new SDK, with configuration and logging
settings.
[[1]](diffhunk://#diff-1087baf076a83b00d0c97ef01c02174668cb26c9fad5d2c33284e0889150ed65R1-R13)
[[2]](diffhunk://#diff-b94b53965e9052345453f2ab6bec21420a36c4b67c9a6c568b9c80edcd0882d1R1-R22)
[[3]](diffhunk://#diff-84b21a8c78e12fee4df3b2d67483407632a1fe5d25691ed7cfefde85adc92a25R1-R11)
-
[`Proactive`](diffhunk://#diff-ffe34fac742569e7a6cfb5589871a8b9571c7692f6af33e167f39cc2b8be3ed3R1-R17):
Demonstrates sending proactive messages using a background worker.
[[1]](diffhunk://#diff-ffe34fac742569e7a6cfb5589871a8b9571c7692f6af33e167f39cc2b8be3ed3R1-R17)
[[2]](diffhunk://#diff-f32e1fd30a40c5aa42855895485dbb9c8b79d4029cd3db1a1446f48846f8604dR1-R10)
[[3]](diffhunk://#diff-61d7e83f772e536a1729f5c12b1b028a2a396a28e2175541489e85d89d2758ecR1-R31)
[[4]](diffhunk://#diff-1342c159b3ce809afd5880d58bd2f17e3eeade347f10d5b8d6d550cb3a0ab8f9R1-R8)
- Added scenario scripts for middleware and proactive messaging,
runnable via dotnet script.
[[1]](diffhunk://#diff-aee4a2e56fbce4adfe46afec84a447a9aab7752f7c24982b51b8475af942124fR1-R34)
[[2]](diffhunk://#diff-8287e53b5a4e259703b929262b11fdb5f783564de364cc184d27a5b7486de729R1-R43)
- Provided an example `launchSettings.json` for local development of
scenarios.

**Compatibility support:**

- Introduced `CompatAdapter` and related classes to bridge new bot
application models with legacy Bot Framework interfaces, enabling easier
migration and integration of existing bots.
[[1]](diffhunk://#diff-ee802b583e856949e14f231284969979f8827efaa484f0b431badb7936809855R1-R116)
[[2]](diffhunk://#diff-e70e201729b0f386ddb70a5d3f83751f2bd0a08e527b0a5265fbb8094a9abe19R1-R27)

**Development environment and documentation improvements:**

- Updated `.devcontainer/devcontainer.json` to add Docker-in-Docker,
.NET 10, and ensure latest feature versions for improved local
development experience.
- Added a `README.md` with instructions for testing and running
scenarios.
- Added common development files to `.gitignore` and included it in the
solution.
[[1]](diffhunk://#diff-af85f59c6492668dca14d5f06b54cc2c3173708c83073e1d947b4c007dc851d6R1-R2)
[[2]](diffhunk://#diff-19ad97af5c1b7109a9c62f830310091f393489def210b9ec1ffce152b8bf958cR4-R12)

**Solution structure updates:**

- Updated `core.slnx` to include new sample projects and `.gitignore` as
solution items.

---

**New sample bots and scenarios:**
- Added `CompatBot`, `CoreBot`, and `Proactive` sample projects with
implementations and configuration files to demonstrate different SDK
usage scenarios.
[[1]](diffhunk://#diff-22411d9bef78e3d139f1e4b1a4d5e047bb26428a97bf59df7f5b983e584babd8R1-R13)
[[2]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aR1-R35)
[[3]](diffhunk://#diff-62be1f70aaabb519334fe39cd50c0e25a98717ebb9fab85b688832917c9c75bbR1-R29)
[[4]](diffhunk://#diff-834a6cbae004839d32944b2f2a3cf8edc3a32f558597d464401178fa95781edcR1-R9)
[[5]](diffhunk://#diff-1087baf076a83b00d0c97ef01c02174668cb26c9fad5d2c33284e0889150ed65R1-R13)
[[6]](diffhunk://#diff-b94b53965e9052345453f2ab6bec21420a36c4b67c9a6c568b9c80edcd0882d1R1-R22)
[[7]](diffhunk://#diff-84b21a8c78e12fee4df3b2d67483407632a1fe5d25691ed7cfefde85adc92a25R1-R11)
[[8]](diffhunk://#diff-ffe34fac742569e7a6cfb5589871a8b9571c7692f6af33e167f39cc2b8be3ed3R1-R17)
[[9]](diffhunk://#diff-f32e1fd30a40c5aa42855895485dbb9c8b79d4029cd3db1a1446f48846f8604dR1-R10)
[[10]](diffhunk://#diff-61d7e83f772e536a1729f5c12b1b028a2a396a28e2175541489e85d89d2758ecR1-R31)
[[11]](diffhunk://#diff-1342c159b3ce809afd5880d58bd2f17e3eeade347f10d5b8d6d550cb3a0ab8f9R1-R8)
- Added scenario scripts for middleware and proactive messaging, plus an
example launch settings file for local testing.
[[1]](diffhunk://#diff-aee4a2e56fbce4adfe46afec84a447a9aab7752f7c24982b51b8475af942124fR1-R34)
[[2]](diffhunk://#diff-8287e53b5a4e259703b929262b11fdb5f783564de364cc184d27a5b7486de729R1-R43)
[[3]](diffhunk://#diff-19cd1809f42bd0d871748a1e3bf7c705961f9abd0a4da67acc547f42c1ebfcd6R1-R20)

**Compatibility support:**
- Introduced `CompatAdapter` and `CompatActivity` to support running
legacy Bot Framework bots with the new SDK.
[[1]](diffhunk://#diff-ee802b583e856949e14f231284969979f8827efaa484f0b431badb7936809855R1-R116)
[[2]](diffhunk://#diff-e70e201729b0f386ddb70a5d3f83751f2bd0a08e527b0a5265fbb8094a9abe19R1-R27)

**Development environment and documentation:**
- Enhanced `.devcontainer` with Docker-in-Docker, .NET 10, and latest
feature versions for improved local development.
- Added a `README.md` with setup and testing instructions.
- Updated `.gitignore` and included it in the solution for better source
control hygiene.
[[1]](diffhunk://#diff-af85f59c6492668dca14d5f06b54cc2c3173708c83073e1d947b4c007dc851d6R1-R2)
[[2]](diffhunk://#diff-19ad97af5c1b7109a9c62f830310091f393489def210b9ec1ffce152b8bf958cR4-R12)

**Solution structure:**
- Updated `core.slnx` to include new projects and configuration files.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rido-min <14916339+rido-min@users.noreply.github.com>
@rido-min rido-min added the CORE label Dec 11, 2025
rido-min and others added 22 commits December 10, 2025 17:46
Updated Azure DevOps pipeline to trigger only on next/* branches and use ubuntu-22.04. Added cd-core.yaml to solution items in core.slnx. Removed null-forgiving operator from CoreActivity.cs return statement for safer null handling.
Added a UseDotNet@2 task to install .NET 8 SDK (8.0.x) before the .NET 10 SDK in the BuildTestPack job. This ensures both SDK versions are available for build and test processes.
Changed package icon to bot_icon.png in project properties. Added ItemGroup to explicitly include bot_icon.png and README.md at the root of the NuGet package during packing.
Added a new bot_icon.png file to the project, providing a graphical asset that can be used as an icon or visual element within the application.
Changed the pipeline condition so that NuGet packages are pushed only when building from the refs/heads/next/core branch, instead of the main branch. This restricts package publishing to the next/core branch.
Ignored launchSettings.json, appsettings.Development.json, and .runsettings to prevent tracking of local configuration and test settings files.
Introduce Microsoft.Bot.Core.Tests targeting .NET 10.0 with xUnit and code coverage. Add core-test.yaml workflow to run these tests with Azure AD credentials. Update solution file to include new test project and workflow. Implement ConversationClientTest for Teams activity scenarios. Update core-ci.yaml to run only unit tests.
Updated the build pipeline to run tests only for the Microsoft.Bot.Core.UnitTests project. Changed environment variable to "TEST_CONVERSATIONID" in ConversationClientTest.cs and corrected the hardcoded conversation ID format by removing the message ID suffix.
- Prefix echo replies with "Echo from BF Compat"
- Change default log level to Warning; add Debug for Microsoft.Bot
- Remove using statement for TurnContext in CompatAdapter
- Expand exception handling to rethrow non-HttpOperationException
- Add debug/info logging to BotApplication activity processing
Introduce .editorconfig for code style and nullable strictness. Update solution to include .editorconfig. Rename CoreActivity.CreateReplyActivity to CreateReplyMessageActivity and update all usages. Extend CoreActivityJsonContext for Int64/Double support. Apply minor formatting fixes and missing braces. Strengthen and update unit tests for new property types and method changes.
Replaced all var declarations with explicit types across the codebase, including tests, bot implementations, and entry points. This improves code clarity and type safety, making variable types more visible and aiding maintainability. No functional changes were made.
Added copyright and MIT license headers to all source and test files.
Updated .editorconfig to enforce file header template for new files.
Made minor code style improvements and access modifier updates. Ensured
consistent attribution and licensing across the codebase.
EchoBot now informs users how to trigger a proactive message via a new `/api/notify/{conversationId}` endpoint. Added a GET endpoint to send proactive messages to a conversation by ID. Updated message handling to support CancellationToken and included necessary usings for proactive messaging support.
Integrate Azure Monitor Application Insights telemetry into both
CompatBot and CoreBot using OpenTelemetry. Update appsettings.json to
include a placeholder Application Insights connection string and adjust
logging levels for better diagnostics. Refactor EchoBot to accept an
ILogger and log version info; comment out some unused message handlers.
Improve CoreBot reply robustness by safely extracting conversation type.
Reformat project files for consistency and explicitly add Azure Monitor
package. Update Proactive Worker to use constants for ServiceUrl and
FromId. Refactor ConversationClient to use StringContent for activity
payloads, ensuring correct JSON serialization and content type.
Removed unnecessary using directives from EchoBot.cs and ConversationClient.cs. Updated TryGetValue in Program.cs to use object? for better type safety and clarity.
Refactored pipeline triggers to use path filters for PRs, targeting only core/** changes. Removed obsolete trigger config and comments. Introduced PushToADOFeed variable to control NuGet push step, replacing branch-based condition.
singhk97 and others added 10 commits February 13, 2026 13:12
- Create Router internally with dedicated logger instead of injecting as
dependency

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
* Added all invoke activities ( some are commented that could not be
tested )
* Added `AllInvokesBot` sample project for adaptive card actions, task
modules, file consent, and other invoke scenarios.
* Added `MessageExtensionBot` sample project.
* Made invoke activity and invoke response strongly typed vi generics.
- Refactored `CompatAdapter` to take in the required objects instead of
the service provider object, and then resolving them through it.
- Introduce `KeyedBotAuthenticationHandler` which configures auth based
on keyed configurations. Add MSAL configurations under a key, and use
that the instantiate this object and viola!
- Update incomming token validation to be based on keyed configurations
as well.
- As a consequence of the above changes, it is possible multiple keyed
instances of `TeamsBotApplication` and `CompatAdapter` allowing for
multiples apps to be hosted in a single process.
- Introduce PABot and CompatProactive samples, that test out PA
scenarios and proactive messaging scenarios, respectively.

**Testing**
- [x] PABot setup working
- [x] PABot EchoBot working
- [ ] PABot TeamsBot working
- [ ] CompatProactive working
- [x] Integration with PA codebase working

---------

Co-authored-by: Kavin Singh <kavinsingh@microsoft.com>
**Core SDK Enhancements:**

* Introduced `EventActivity` and `EventActivity<TValue>` classes to
represent event activities, including strongly-typed value payloads.
Also added `EventNames` constants for meeting event types.
* Defined strongly-typed value classes for meeting events:
`MeetingStartValue`, `MeetingEndValue`, `MeetingParticipantJoinValue`,
and `MeetingParticipantLeaveValue`, as well as related participant info
classes.
* Added `MeetingHandler.cs` with extension methods for registering
handlers for meeting start, end, participant join, and participant leave
events in `TeamsBotApplication`.

**Sample Bot and Documentation:**

* Added a new sample bot, `MeetingsBot`, including its project file,
implementation (`Program.cs`), configuration (`appsettings.json`), and a
detailed README explaining manifest requirements and Teams setup for
meeting events.
* Updated the solution file `core.slnx` to include the new `MeetingsBot`
sample.
Introduced ReplyToId property in CoreActivity and builder, enabling
reply tracking in activities. Updated ConversationClient to append
ReplyToId to outgoing URLs and adjusted "agents" channel ID truncation.
Simplified bot setup in Program.cs by removing telemetry and generic
parameters. Added a default route overload for UseBotApplication. Minor
logging and comment improvements.

This pull request introduces improvements to how reply handling is
managed in the bot framework, particularly around supporting and
propagating the `ReplyToId` property in activities. The changes ensure
that reply chains are correctly maintained and that conversation IDs are
truncated to the correct length for the 'agents' channel. Additionally,
the API for registering the bot application has been streamlined.

**Reply handling and activity schema improvements:**

* Added a `ReplyToId` property to the `CoreActivity` class, enabling
activities to specify which message they are replying to.
* Updated `CoreActivityBuilder` to set `ReplyToId` when copying from
another activity and added a `WithReplyToId` method for explicit
setting.
[[1]](diffhunk://#diff-5e00975e375bcb87e6b0d28d2367d865865a1254f089cfcab0d6abbb5db4be38R52-R56)
[[2]](diffhunk://#diff-5e00975e375bcb87e6b0d28d2367d865865a1254f089cfcab0d6abbb5db4be38R86-R96)

**Message sending and routing improvements:**

* Modified `SendActivityAsync` in `ConversationClient` to append
`ReplyToId` to the outgoing message URL if present, ensuring replies are
correctly threaded. Also, fixed conversation ID truncation for the
'agents' channel to a maximum of 100 characters (was 325).
* Added a new overload of `UseBotApplication` to simplify bot
application setup with a default route.

**Sample and registration cleanup:**

* Updated the sample bot (`CoreBot/Program.cs`) to use the new
`AddBotApplication` and `UseBotApplication` APIs, and cleaned up reply
message formatting.
## Summary

- Decoupling `IConfiguration` from the `TeamsBotApplication` and
`BotApplication` classes since it's not clear what configurations are
required.

## Test plan

- [x] Verify bot starts and logs the correct AppID at startup
- [x] Test with each config format: `MicrosoftAppId`, `CLIENT_ID`, and
`AzureAd:ClientId`
- [x] Confirm `BotApplicationOptions.AppId` defaults to empty string
when no config key is present

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
When setting up components manually BotApplicationOptions is probably
the least important argument. So it makes sense to make it optional.

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
- All matching routes now run sequentially for non-invoke activities.
Previously only the first matching route executed, silently swallowing
any subsequent handlers.
   Registration order is preserved.
- Invoke routing remains first-match-wins. Invoke activities require
exactly one InvokeResponse back to Teams — running multiple handlers is
undefined behaviour.
- Startup throws if OnInvoke and specific invoke handlers are mixed.
Registering both OnInvoke and eg. OnAdaptiveCardAction guarantees one
response is silently swallowed. The valid approaches are: OnInvoke
exclusively with an internal if/else, or specific handlers exclusively.
- Startup throws if the same route is registered twice. Duplicate
registration is assumed to be a bug.
- Removed ILogger from Router. The logger passed was
ILogger<TeamsBotApplication>. Startup errors now throw
  exceptions instead of logging.
## No new features; focus is on code quality.


Explicit types replace var throughout for improved readability and
maintainability. Formatting and whitespace are standardized. Property
accessors use object? for nullability. Dependency injection and routing
use explicit types. Comments and documentation clarified. Minor bug
fixes and copyright headers updated.
This pull request primarily focuses on code cleanup and modernization
across several files, including improvements to copyright headers,
variable declarations, and import ordering. The changes help standardize
the codebase and make it more readable and maintainable.

**Copyright and Licensing Updates:**
* Updated copyright headers in `Route.cs` and `Router.cs` to remove "All
rights reserved" and ensure consistency with MIT licensing.
[[1]](diffhunk://#diff-770b878e7b1d580f51d38d08640ad9a37b9234dd9f80d1365738f44f225a8f56L1-R1)
[[2]](diffhunk://#diff-39661a1e6d086cf06cff19e9627a3424084ccb66df2254a6b56623ef4ccf5016L1-R3)
* Added proper copyright and licensing information to
`GlobalSuppressions.cs`.

**Code Style Improvements:**
* Replaced explicit variable declarations with type inference (e.g.,
`var` → `List<RouteBase>`) in `Router.cs` to improve readability and
clarity.
[[1]](diffhunk://#diff-39661a1e6d086cf06cff19e9627a3424084ccb66df2254a6b56623ef4ccf5016L65-R74)
[[2]](diffhunk://#diff-39661a1e6d086cf06cff19e9627a3424084ccb66df2254a6b56623ef4ccf5016L91-R92)
* Updated regex instantiation in `MessageHandler.cs` to use target-typed
`new` for conciseness.

**Import and Namespace Ordering:**
* Reordered and cleaned up using statements in `EchoBot.cs`,
`Program.cs`, and `SimpleGraphClient.cs` for better organization and
consistency.
[[1]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL7-R13)
[[2]](diffhunk://#diff-62be1f70aaabb519334fe39cd50c0e25a98717ebb9fab85b688832917c9c75bbL6-R10)
[[3]](diffhunk://#diff-891dee2b4796177cac44609d7ec803a964633f9f214eb096a70aa612910c2ce6R10-L15)
* Removed unnecessary using statements in `Context.cs`.

**Type Safety Enhancements:**
* Improved type safety in `ConversationUpdateActivity.cs` by explicitly
specifying `object?` in property retrievals.
[[1]](diffhunk://#diff-8f9b05b82c5484251ba864fad6bd6ec711ff8b9d4ef23929c7122f8cbc23f05aL68-R68)
[[2]](diffhunk://#diff-8f9b05b82c5484251ba864fad6bd6ec711ff8b9d4ef23929c7122f8cbc23f05aL81-R81)
# Motivation

We expect developers to have `LogInformation` statements (and hence
greater log levels) enabled in production. And so it should provide just
enough information to be achieve the following goals:
- Be able to identify the issues by tracing logs through internal
activity processing pipeline.
- Get suggestions when incomming activity is not handled.
- Have access to metadata that helps us, as SDK owners, with debugging.
- No PIIs should be logged.
- Logs shouldn't be too verbose or contain redundant information.

# Changes
- Removed `BeginScope` since it will add the passed context to every log
statement, forcing the developer to manually configure filtering in
their logging infrastructure.
- On `BotApplication.ProcessAsync` add logging of the MSCV & ServiceUrl.

# How logs look like right now

<img width="1399" height="223"
alt="ae4f3ffc-02ef-40d0-ae81-89848948cde1"
src="https://github.com/user-attachments/assets/e04fe979-83f0-45de-8837-435d809e0a50"
/>

# Program flow and where info logs are present

```mermaid
flowchart TD
      A["Teams Service (POST /api/messages)"]
      B["JWT token validation <br/>ℹ️ token validated successfully "]
      C["BotApplication.ProcessAsync<br/>ℹ️ Activity received <br/>ℹ️ Finished processing activity"]
      D["TurnMiddleware Pipeline"]
      E["TeamsBotApplication.OnActivity<br/>ℹ️ Routing incoming activity"]
      F["Router <br/> ⚠️ no routes found, or registered"]
      G["User Handler"]
      H["ConversationClient  <br/>ℹ️ sending message to url" ]
      I["BotAuthenticationHandler <br/>ℹ️ Acquiring token for scope"]
      J["APX <br/>"]

      A --> B --> C --> D --> E --> F --> G --> H --> I --> J
```
rido-min and others added 19 commits March 3, 2026 17:09
…lds) (#360)

This pull request introduces comprehensive changes to support
nullability for key properties in activity-related classes and their
usage throughout the codebase. The main goal is to improve robustness
when handling activities that may lack sender, recipient, or
conversation information, and to ensure consistent null handling in both
implementation and tests.

Key changes include:

- Making `From`, `Recipient`, and `Conversation` properties nullable in
activity and related classes.
- Updating constructors, methods, and serialization logic to handle
possible null values.
- Adjusting tests to account for and verify nullability.

The most important changes are:

**Core Schema and Model Updates:**

* Made the `From`, `Recipient`, and `Conversation` properties nullable
in `CoreActivity`, `TeamsActivity`, and related classes, and updated
constructors to handle null inputs gracefully. This ensures activities
can be created and processed even when some participants or conversation
info are missing.
[[1]](diffhunk://#diff-aa65632fe28a87aec3d29025384c7f1e687d5839d848f1220e8ed59e76dcd35bL55-R63)
[[2]](diffhunk://#diff-b9fe8c2661f373312865c34021dcd68b97c7a7308d3814767e941a9e275212f4L100-R134)
[[3]](diffhunk://#diff-ab03c7985a1673a73536a9756293c78cba898a0de6197501e596ad144582a41aL31-R36)
[[4]](diffhunk://#diff-5b4ce81153a4e786cdcc3ed1fce3951c3285b532d484ec1df6b20d9e40a359e4L48-R54)
* Changed entity and attachment collections (`EntityList`,
`TeamsAttachment`) to return `null` instead of empty collections when
input JSON arrays are null, standardizing the nullability contract.
[[1]](diffhunk://#diff-54676e96eda404a3efa65124857df40e5cb3e19ec4a2b1222c9e08cacac8eaa0L46-R50)
[[2]](diffhunk://#diff-7d6dee59c1c828283d2d29d6f55c39949d8a35887c613f85643286c553e6f1a3L118-R122)

**Method and API Usage Adjustments:**

* Updated various method signatures and internal usages to accept
nullable types and to check for nulls before accessing properties,
including in `WithFrom`, `WithRecipient`, and `WithConversation` builder
methods, and in `AgenticIdentity` extraction logic.
[[1]](diffhunk://#diff-5e00975e375bcb87e6b0d28d2367d865865a1254f089cfcab0d6abbb5db4be38L147-R152)
[[2]](diffhunk://#diff-21605a1ddfd84b8b511a41a957d5e130441cf05eb3dc192579480425e0746a0aL58-R58)
[[3]](diffhunk://#diff-2b447b715e5c577302421ca232985ced9354b64def7b26219525758928d097daL61-R61)
[[4]](diffhunk://#diff-d62a8ce4aac677906758eb430b84c9432f61ff95342701fdcae909310e2aed27L69-R69)
[[5]](diffhunk://#diff-d62a8ce4aac677906758eb430b84c9432f61ff95342701fdcae909310e2aed27L99-R99)
[[6]](diffhunk://#diff-d62a8ce4aac677906758eb430b84c9432f61ff95342701fdcae909310e2aed27L153-R153)
[[7]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL152-R152)

**Test Suite Updates:**

* Updated unit tests to expect nulls for properties and collections
where appropriate, and to use null-safe assertions and property access
throughout.
[[1]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL23-R25)
[[2]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL115-R116)
[[3]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL132-R133)
[[4]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL152-R154)
[[5]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL171-R172)
[[6]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL262-R262)
[[7]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL292-R292)
[[8]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL415-R415)
[[9]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL450-R454)
[[10]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL536-R536)
[[11]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL551-R551)
[[12]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL679-R680)
[[13]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL697-R698)
[[14]](diffhunk://#diff-ec253b7d2876187c3585381aa6cd8b1cbfca2227eb6ac23752253bbcda19484fL714-R714)

**Constructor and Null Handling Improvements:**

* Constructors for `TeamsConversationAccount` and `TeamsConversation`
now handle null arguments without throwing exceptions, returning early
if input is null.
[[1]](diffhunk://#diff-ab03c7985a1673a73536a9756293c78cba898a0de6197501e596ad144582a41aL31-R36)
[[2]](diffhunk://#diff-5b4ce81153a4e786cdcc3ed1fce3951c3285b532d484ec1df6b20d9e40a359e4L48-R54)

**General Codebase Consistency:**

* Ensured all usages of `From`, `Recipient`, `Conversation`, `Entities`,
and `Attachments` are null-safe across the codebase, including in
activity updates, deletions, and proactive messaging scenarios.
[[1]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL152-R152)
[[2]](diffhunk://#diff-b9fe8c2661f373312865c34021dcd68b97c7a7308d3814767e941a9e275212f4R74-R88)

These changes collectively make the bot framework more resilient to
incomplete or partially populated activities and improve code safety and
clarity when handling optional data.
- Removed TeamsBotApplicationBuilder and static CreateBuilder/Run
pattern.
- Introduced DI-based AddTeamsBotApplication<TApp>() and
UseTeamsBotApplication<TApp>() extension methods for flexible bot
registration and endpoint configuration.
- Added CustomHosting sample project demonstrating custom
TeamsBotApplication subclassing and registration.
- Renamed ITurnMiddleWare to ITurnMiddleware; updated middleware usage
to UseMiddleware.
- Made ConversationClient and UserTokenClient methods virtual for
extensibility.
- Improved type safety, replaced var with explicit types, and modernized
code style across samples and tests.
- Updated all samples to use new hosting and middleware APIs.
- Improved documentation, error handling, and code consistency.
- No breaking changes for DI-based consumers; legacy builder pattern
removed.

This pull request introduces a new `CustomHosting` sample to demonstrate
custom hosting scenarios for Teams bots, and applies a variety of
improvements and modernizations across several existing bot samples. Key
changes include the addition of the `CustomHosting` project, improved
type safety, modernization of code patterns, and minor cleanup of unused
usings and dependencies.

**New Sample: Custom Hosting**

* Added a new sample project `CustomHosting`, including
`CustomHosting.csproj`, `MyTeamsBotApp.cs`, `Program.cs`, and
`appsettings.json`, to demonstrate how to set up and run a Teams bot
application with custom hosting logic. (`core/core.slnx`,
`core/samples/CustomHosting/CustomHosting.csproj`,
`core/samples/CustomHosting/MyTeamsBotApp.cs`,
`core/samples/CustomHosting/Program.cs`,
`core/samples/CustomHosting/appsettings.json`)
[[1]](diffhunk://#diff-19ad97af5c1b7109a9c62f830310091f393489def210b9ec1ffce152b8bf958cR18)
[[2]](diffhunk://#diff-9a0a358fefed3a2d514a075dde6393f9d54f88b65e6701443355af6741f8ce80R1-R13)
[[3]](diffhunk://#diff-ec0a36e06aeb2c4f3f7620e01891a6123198cfac9bf6bf1e851ccd913e5b8440R1-R20)
[[4]](diffhunk://#diff-71299e3fd10a90f2601fa1e84cdda5006a3cf3676a2fb32e2ef1e830608558f2R1-R15)
[[5]](diffhunk://#diff-1741a37e03d344704fdb47a90f621df777f6d1888075ec76923bb392ac4e5d0cR1-R9)

**Type Safety and Modernization**

* Improved type safety and code clarity in multiple samples by using
explicit types (e.g., `ChatMessage?`, `SendActivityResponse?`,
`JObject?`, `IList<MeetingParticipantMember>`, etc.), nullable reference
types, and modern C# object initializers.
(`core/samples/AFBot/Program.cs`, `core/samples/CompatBot/EchoBot.cs`,
`core/samples/MeetingsBot/Program.cs`,
`core/samples/AllInvokesBot/Program.cs`,
`core/samples/MessageExtensionBot/Program.cs`)
[[1]](diffhunk://#diff-b2eaa16ee58a54a25acb5e930ace0fe03ca3dea7b34c67a265dcddc8500ae41bL48-R57)
[[2]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL50-R54)
[[3]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL81-R96)
[[4]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL126-R132)
[[5]](diffhunk://#diff-b0cc7807e2f91f921ec82978833465533c565f637b0aa56802f0d713f6688306L15-R38)
[[6]](diffhunk://#diff-8f290ac497e620d9799b6a57476f6d5051a39df15e2bb71755ffb6849d2b1b35L31-R47)
[[7]](diffhunk://#diff-8f290ac497e620d9799b6a57476f6d5051a39df15e2bb71755ffb6849d2b1b35L51-R58)
[[8]](diffhunk://#diff-8f290ac497e620d9799b6a57476f6d5051a39df15e2bb71755ffb6849d2b1b35L91-R99)
[[9]](diffhunk://#diff-8f290ac497e620d9799b6a57476f6d5051a39df15e2bb71755ffb6849d2b1b35L113-R130)
[[10]](diffhunk://#diff-9da189387a8b06507339b8044bf5a572c0f84620969ebe735248a73252da901fL33-R33)

* Updated middleware usage patterns and naming to align with modern
conventions (e.g., using `UseMiddleware` instead of `Use`, fixing
interface name typo from `ITurnMiddleWare` to `ITurnMiddleware`).
(`core/samples/AFBot/DropTypingMiddleware.cs`,
`core/samples/AFBot/Program.cs`)
[[1]](diffhunk://#diff-b921767a8b614972c7a3bb5308b4fd797c60d44de331b9656065f3adbee7a248L9-R9)
[[2]](diffhunk://#diff-b2eaa16ee58a54a25acb5e930ace0fe03ca3dea7b34c67a265dcddc8500ae41bL31-R32)

**Dependency and Usings Cleanup**

* Removed unused or redundant `using` statements from several files for
clarity and maintainability.
(`core/samples/CompatProactive/ProactiveWorker.cs`,
`core/samples/CompatBot/Cards.cs`, `core/samples/CoreBot/Program.cs`,
`core/samples/AllInvokesBot/Cards.cs`)
[[1]](diffhunk://#diff-cb27bc8500d98e9cd996a878c9d25274502563720748d6ba31525b75e46bbc46L4-L8)
[[2]](diffhunk://#diff-cef44960d160cf6ea51b595745c079353501a962650d7c9684bd9fa6e1456220L4-L6)
[[3]](diffhunk://#diff-b94b53965e9052345453f2ab6bec21420a36c4b67c9a6c568b9c80edcd0882d1L4)
[[4]](diffhunk://#diff-935a6ffb850a503e4af48c17543f2215a7ab022dd4835efb60f8207c01698520L5)

**Project and Build System Updates**

* Added the new `CustomHosting` sample to the solution file `core.slnx`
for inclusion in the build.

**Minor Fixes and Consistency Improvements**

* Standardized variable naming and initialization, improved null
handling, and modernized HTTP client usage in the AllInvokesBot and
other samples. (`core/samples/AllInvokesBot/Program.cs`)
[[1]](diffhunk://#diff-8f290ac497e620d9799b6a57476f6d5051a39df15e2bb71755ffb6849d2b1b35L31-R47)
[[2]](diffhunk://#diff-8f290ac497e620d9799b6a57476f6d5051a39df15e2bb71755ffb6849d2b1b35L51-R58)
[[3]](diffhunk://#diff-8f290ac497e620d9799b6a57476f6d5051a39df15e2bb71755ffb6849d2b1b35L91-R99)
[[4]](diffhunk://#diff-8f290ac497e620d9799b6a57476f6d5051a39df15e2bb71755ffb6849d2b1b35L113-R130)
[[5]](diffhunk://#diff-8f290ac497e620d9799b6a57476f6d5051a39df15e2bb71755ffb6849d2b1b35L283-R288)

These changes collectively improve the maintainability, clarity, and
extensibility of the sample bots, while providing a new example for
custom hosting scenarios.
Port `CitationEntity` and supporting types from main, adapted for
`next/core`.

- Adds `AddCitation`, `AddAIGenerated`, and `AddFeedback` methods to
`TeamsActivity`
- Enables `OMessage` sub-dispatch in `EntityList.FromJsonArray()` with
`@type` routing (`"Message"` --> `CitationEntity`, `"CreativeWork"` -->
`SensitiveUsageEntity`)
- Adds typed `FeedbackLoopEnabled` property to `TeamsChannelData`
- Registers new citation types in `TeamsActivityJsonContext`:
(`CitationEntity`, `CitationClaim`, `CitationAppearanceDocument`,
`CitationImageObject`, `CitationAppearance`)
- Registers previously missing entity types in
`TeamsActivityJsonContext`: (`OMessageEntity`, `SensitiveUsageEntity`,
`DefinedTerm`, `ProductInfoEntity`, `StreamInfoEntity`)
- Unit tests

### Notes
- Not porting `UpdateEntity(IEntity, IEntity`); `AddCitation` does
remove + add inline
- `Samples.AI/CitationsHandler` not ported
- `IMessageEntity` not needed - concrete classes only in 2.1
- `IMessageJsonConverter` replaced by `DeserializeMessageEntity` in
EntityList

---------

Co-authored-by: Corina Gum <>
### New Sample Project: TabApp

- Added `TabApp` sample project to the solution and project files,
including its backend and frontend components.
- Implemented backend logic in `Program.cs` for serving static tab
content, handling Teams authentication, and providing server functions
such as posting messages to chat.

### Frontend Implementation

- Added a React/Vite frontend app with Teams JS SDK and MSAL
integration, supporting features like context display, posting to chat,
user info lookup, and presence toggling.

### Auth
- Added entra token validation and cleaned up jwtExtension
In PA one bot will have two registrations, a normal one and an agentic
one. This means both will have separate client ids and so incomming
token validation should be able to handle both setups.
Documentation improvements:

* For conversation update, event, meeting, and install/update handlers,
all matching handlers are now invoked sequentially rather than only the
first one. This is a breaking change and is documented in the XML
comments for each registration method.

Invoke handler registration restrictions:

* Catch-all invoke handlers (registered via `InvokeExtensions.OnInvoke`)
can no longer be combined with specific invoke handlers (such as
adaptive card or file consent handlers). This restriction is now
enforced and documented as a breaking change.

General cleanup:

* Removed outdated TODO comments and clarified remarks in the
`Context.cs` file.
…ion client (#369)

### Compatibility layer improvements

* Introduced `FromCompatChannelAccount` and
`FromCompatConversationParameters` extension methods in
`CompatActivity.cs` to convert Bot Framework objects to Teams Core
schema, mapping relevant fields and properties.
* Updated `CompatConversations.cs` to use the new
`FromCompatConversationParameters` method for conversation creation,
ensuring full compatibility and proper field mapping.

### Testing

* Added unit tests in `CompatActivityTests.cs` for the new conversion
methods, covering field mapping, null handling, and property population.
Fixed two instances where AddBotAuthentication overloads were called
with parameters in the wrong order:
- Line 39: The sectionName-based overload was passing parameters as
(schemeName, clientId, tenantId, logger) instead of the correct
(clientId, tenantId, schemeName, logger)
- Line 59: The IServiceCollection overload had the same parameter
ordering issue

This ensures that clientId, tenantId, and schemeName are passed to the
correct parameter positions, preventing authentication configuration
errors.

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This PR updates the next/core branch with the latest changes from main.


This pull request introduces significant improvements to the build and
release pipelines for the Teams SDK, including new YAML pipeline files,
refactoring of existing pipelines, and enhancements to the `Activity`
class in the codebase. The changes streamline CI/CD processes, add
support for targeted activities, and improve test result publishing.

Pipeline and CI/CD improvements:

* Added new pipeline files: `.azdo/publish-preview.yaml` for preview
package publishing (manual trigger, supports both internal and public
feeds), `.azdo/publish.yml` for public releases, and
`.azdo/templates/sign-and-pack.yaml` as a shared signing and packing
template. These changes centralize and simplify the release workflow for
internal and public NuGet packages.
[[1]](diffhunk://#diff-385304594914fc0af74bf0fbf7b2bb77eaadd30a583d8b2b4e928db730f5892bR1-R158)
[[2]](diffhunk://#diff-186607033cddd78a2207f2b7acc82e3724148a6703c76d5f45f308a837c7e920R1-R5)
[[3]](diffhunk://#diff-df3149e4326765add7763e50ab1569eaa4b619ebc212e2e9b7498854e8c7dd76R1-R94)
* Refactored `.azdo/ci.yaml` and `.azdo/cd-core.yaml` to improve
triggers, test result publishing, artifact naming, and build
configuration handling. This includes switching artifact names to
`Packages`, publishing test results, and using variables for build
configuration.
[[1]](diffhunk://#diff-d9306c7aa179daae2a93bd588f2df485e65c72de402e1afa7c65efa3f105b825R1-R7)
[[2]](diffhunk://#diff-d9306c7aa179daae2a93bd588f2df485e65c72de402e1afa7c65efa3f105b825L36-R67)
[[3]](diffhunk://#diff-54d52e0bc1c296e6fbaf6daa1236b02f1645a2a1609a7129e4185d0de161e1ebR1-R6)
[[4]](diffhunk://#diff-54d52e0bc1c296e6fbaf6daa1236b02f1645a2a1609a7129e4185d0de161e1ebL68-R74)
* Updated `.github/workflows/codeql.yml` to include the `next/core`
branch in CodeQL analysis for improved security coverage.

Enhancements to the `Activity` class and related activities:

* Added an experimental `IsTargeted` property to `Activity`, with
related methods and merge logic, allowing activities to indicate if they
are targeted. This includes new overloads for `WithRecipient` and proper
merging behavior.
[[1]](diffhunk://#diff-875c3804dbdc89735553c417d023929c307dcfbead113a1b7a1e47871cab636aR149-R152)
[[2]](diffhunk://#diff-875c3804dbdc89735553c417d023929c307dcfbead113a1b7a1e47871cab636aR230-R242)
[[3]](diffhunk://#diff-875c3804dbdc89735553c417d023929c307dcfbead113a1b7a1e47871cab636aR433-R439)
* Refactored `Value` property overrides in several activity classes
(`ActionActivity`, `HandoffActivity`, `AnonQueryLinkActivity`,
`FetchTaskActivity`) to use explicit getter/setter logic, improving type
safety and clarity.
[[1]](diffhunk://#diff-8039eb42926eb743d838475a9692396f17a72ef33f1fdbc1883b59524835ef72L28-R32)
[[2]](diffhunk://#diff-cf9ec41b68de548f026e472cc44faea40af2f9415d91e56baba5eab6849c7243L23-R27)
[[3]](diffhunk://#diff-2e64b26a5c79daa8c735a79d1d0ef7b177757824825771d0e555d0175e0e105fL28-R32)
[[4]](diffhunk://#diff-f0921d5ad7f9df3408669c99b9d12809568feddde82f1521621301ad84cd21f0L28-R32)

These changes collectively modernize and standardize the build, test,
and release process, while also expanding SDK functionality for targeted
activities.

---------

Co-authored-by: Shanmathi Mayuram Krithivasan <37715033+ShanmathiMayuramKrithivasan@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rido-min <14916339+rido-min@users.noreply.github.com>
Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Mehak Bindra <mhk0397@gmail.com>
Co-authored-by: Alex Acebo <aacebowork@gmail.com>
Co-authored-by: Kavin <115390646+singhk97@users.noreply.github.com>
## Summary
  - Sanitize MS-CV header value to prevent log forging attacks
  - Remove newline characters before logging
  - Add comprehensive unit tests

  ## Context
Addresses CodeQL security warning: user-provided MS-CV header values
were logged without sanitization, allowing
  malicious users to inject fake log entries via newline characters.

  🤖 Generated with Claude Code

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Rido <rido-min@users.noreply.github.com>
…oing activity. (#374)

1. Refactor PA bot - remove multi-host setup, support two identities
simulatneously (bot & agent)
2. **[PA bug fix]** In `Microsoft.Teams.Bot.Compat`, If `serviceUrl` is
not set in outgoing activity then use the one from the incomming
activity as fallback
3. Make `ConversationAccount.GetAgentIdentity()` public. It's being used
in the compat adapter.

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Rido <rido-min@users.noreply.github.com>
This pull request introduces several enhancements and new features to
the Teams bot sample applications, focusing primarily on expanding the
message handling capabilities, adding support for task modules, and
improving targeted messaging and reactions. Additionally, it includes
some cleanup and configuration changes.

**Major new features and improvements:**

_Message handling and bot capabilities:_

* Added new message handlers in `TeamsBot/Program.cs` for commands such
as `help`, `targeted`, `react`, `card`, `feedback`, and `task`, each
demonstrating specific Teams bot features like targeted messages,
reactions, adaptive cards, and task modules.
[[1]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bR19-R49)
[[2]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bR122-R238)
* Introduced a detailed help handler that lists available message
patterns and commands, improving discoverability for users.
* Enhanced the catch-all handler to echo messages with a mention and
provide guidance to users.
* Improved lifecycle event handling by reordering and clarifying message
update and delete handlers.
[[1]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bL118-R284)
[[2]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bL158-R310)

_Task module support:_

* Added two new Adaptive Card definitions, `TaskModuleLauncherCard` and
`TaskModuleFormCard`, in `Cards.cs` to support task module dialogs.
* Implemented handlers for task module fetch and submit events, enabling
the bot to display a form in a dialog and process the submitted data.

_Targeted messaging and reactions:_

* Added handlers and logic to demonstrate sending, updating, and
deleting targeted messages, as well as adding and removing reactions to
messages, both in the main Teams bot sample and in the `CompatBot`
sample.
[[1]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bR122-R238)
[[2]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL39-R93)

_Other improvements and cleanup:_

* Fixed the documentation URL for the Teams SDK in the citation handler.
* Updated `.gitignore` to exclude the `.claude/` directory.
* Removed the now-unnecessary `.claude/settings.local.json`
configuration file.
* Minor code cleanup and dependency ordering in
`RoutedTokenAcquisitionService.cs` and `EchoBot.cs`.
[[1]](diffhunk://#diff-49a16dd3d7f594e27c7dd21596874e089adf4f5f2fc7ef24a41f028035834163R4-L6)
[[2]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL11)
[[3]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL23-R22)

**References:**  

[[1]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bR19-R49)
[[2]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bR122-R238)
[[3]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bL118-R284)
[[4]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bL158-R310)
[[5]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bL178-R360)
[[6]](diffhunk://#diff-cc765b586b9be67733b494a4fdd0dffee5c3641f29ec07a1d4ddc0ebc0f709c8R61-R143)
[[7]](diffhunk://#diff-af85f59c6492668dca14d5f06b54cc2c3173708c83073e1d947b4c007dc851d6R4-R5)
[[8]](diffhunk://#diff-7c41c1a079a34ad9d167680c2029c93f0e4568a85e4ea589d96c0704bdce6e70L1-L8)
[[9]](diffhunk://#diff-49a16dd3d7f594e27c7dd21596874e089adf4f5f2fc7ef24a41f028035834163R4-L6)
[[10]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL11)
[[11]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL23-R22)
[[12]](diffhunk://#diff-b9be640e365d9187b0d1a2021dddb84311b737f8c28b16428e3b2a450a4f331aL39-R93)
[[13]](diffhunk://#diff-691809f7a90c5bda6ee5e4335c2c393864a32101545fb0b35c24bc659623361bL78-R106)

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
**New StreamingBot sample:**

* Added the `StreamingBot` sample project to the solution and
implemented its main logic in `Program.cs`. The bot streams responses
from OpenAI, progressively updating the message in Teams and including
citations and adaptive cards.

**Streaming message support in Teams SDK:**

* Introduced the `TeamsStreamingWriter` class for managing streaming
message updates, supporting informative, intermediate, and final chunks,
and handling entities and attachments.
* Added the `GetStreamingWriter()` method to the `Context` class,
enabling easy creation of streaming writers in bot logic.

**Schema and serialization improvements:**

* Added the `TypingActivity` class to represent intermediate streaming
updates, including serialization support and integration into the
activity type system.
Key changes:
*  Channel shared, unshared, member added, member removed now working. 

**Sample Bot Event Handlers (TeamsChannelBot/Program.cs):** -> member
added, member removed, shared, unshared is registered once and in the
correct place. The `OnChannelRestored` handler remains commented out due
to lack of testability.

**Event Type Constants
(Schema/Activities/ConversationUpdateActivity.cs):** -> Fixed the casing
of the `ChannelUnShared` event constant to `channelUnshared` .
Introduce LoggerExtensions with LogInformationGuarded and
LogTraceGuarded to prevent expensive log message construction when not
enabled. Replace direct LogInformation and LogTrace calls with guarded
versions in core classes. Remove CA1873 suppression and update CA2227
justification. Improves logging performance and consistency.
- Added a new Adaptive Card for time off requests and updated the "card"
handler to use it.
- Introduced WelcomeMessageMiddleware to send a help message on first
interaction; refactored "help" handler to reuse this message.
- Improved "hello" handler to mention the user and show typing.
- Commented out the catch-all echo handler to reduce noise.
- Added OnMessageSubmitAction handler to process Adaptive Card
submissions.
- Minor cleanups: removed verbose logging and improved code structure.
This pull request introduces a new `SuggestedActions` feature for
message activities, enabling quick reply buttons and card actions in
Microsoft Teams bots. The changes include new schema classes, extension
methods for easier usage, and comprehensive unit tests to ensure correct
serialization, deserialization, and fluent API behavior.

**Schema and Serialization Enhancements:**

* Added new `CardAction` and `SuggestedActions` classes to represent
quick reply actions and their recipients, including common action types
as constants. (`core/src/Microsoft.Teams.Bot.Apps/Schema/CardAction.cs`,
`core/src/Microsoft.Teams.Bot.Apps/Schema/SuggestedActions.cs`)
[[1]](diffhunk://#diff-4c159b3af4206d04ce4994d2775b93613c4c5827d7183a55042b04bacad8af07R1-R131)
[[2]](diffhunk://#diff-ee8ce6b3eb82cc49311f75430d57fd1dd69a0feb1d781cbf2cbe7b3cdca5ba95R1-R68)
* Registered `CardAction` and `SuggestedActions` for JSON serialization
in `TeamsActivityJsonContext`.
(`core/src/Microsoft.Teams.Bot.Apps/Schema/TeamsActivityJsonContext.cs`)

**Integration with MessageActivity:**

* Integrated `SuggestedActions` property into `MessageActivity`,
including support for deserialization from JSON and removal of legacy
code.
(`core/src/Microsoft.Teams.Bot.Apps/Schema/Activities/MessageActivity.cs`)
[[1]](diffhunk://#diff-6f59d077bae6751d429a1458ffb982780671be62e09027244661405f0baad1a2R75-R86)
[[2]](diffhunk://#diff-6f59d077bae6751d429a1458ffb982780671be62e09027244661405f0baad1a2R138-R143)
[[3]](diffhunk://#diff-6f59d077bae6751d429a1458ffb982780671be62e09027244661405f0baad1a2L162-L164)
[[4]](diffhunk://#diff-6f59d077bae6751d429a1458ffb982780671be62e09027244661405f0baad1a2L266-L280)
[[5]](diffhunk://#diff-6f59d077bae6751d429a1458ffb982780671be62e09027244661405f0baad1a2R4)

**Developer Experience Improvements:**

* Added extension methods to simplify adding and chaining suggested
actions to message activities.
(`core/src/Microsoft.Teams.Bot.Apps/Schema/SuggestedActionsExtensions.cs`)

**Testing and Validation:**

* Introduced a comprehensive unit test suite to verify all aspects of
the new suggested actions feature, including serialization,
deserialization, fluent API, and extension methods.
(`core/test/Microsoft.Teams.Bot.Apps.UnitTests/SuggestedActionsTests.cs`)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reorganize Teams activity classes (e.g., MessageActivity,
InvokeActivity, EventActivity, etc.) from the Schema namespace into the
new Handlers namespace and file structure. Update all relevant usings
and references throughout the codebase. No functional changes—this
improves code organization and maintainability by clarifying the
separation between schema definitions and activity handlers. Also
includes minor clarity improvements in StreamingWriter.

One benefit of this organization for activities, is that make it clear
which activities are _incoming_ from the handlers, and which ones are
_outgoing_ in Schema.
1. Fix missing `RequireAuthorization` in CompatBot sample.
2. Refactor service collection setup.
3. Use `BotConfig` as single source for reading & propagating
configuration instead of doing that all over.
4. Move Msal setup logic to separate class
5. Support scenario where auth is not provided. Warning logs will be
emitted. Clients will be created without auth. Incomming token
validation will use a bypass scheme.

# Logs when setting up auth using the different config formats
## No credentials setup
<img width="1096" height="137" alt="image"
src="https://github.com/user-attachments/assets/8ed049bb-13a2-4858-9328-560696b34f6e"
/>

### Testing with Agents Plaground

<img width="1202" height="216" alt="image"
src="https://github.com/user-attachments/assets/3ca23613-e725-4fda-8d8a-7867185bce74"
/>

edit: it had multiple redundant logs before

## Msal Config setup
<img width="1098" height="179" alt="image"
src="https://github.com/user-attachments/assets/52ff919c-37bf-4077-8cbf-ce9db00cf1c8"
/>

## Core config setup

<img width="717" height="292" alt="image"
src="https://github.com/user-attachments/assets/2ce6adf6-0d3e-4abf-a986-185ea0bb1b99"
/>


## BF config setup

<img width="1049" height="291" alt="image"
src="https://github.com/user-attachments/assets/cdc80a0c-23af-43cc-afc6-408281d216db"
/>

---------

Co-authored-by: Rido <rido-min@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants