Flow bot request context through BotBuilder compat clients#594
Conversation
Ensure BotBuilder compat conversation and user token calls pass BotRequestContext through to core clients for both reactive and proactive turns. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR threads BotRequestContext through the BotBuilder compatibility layer so downstream core HTTP clients (conversation + user token) can authenticate/act using per-request bot identity (and agentic identity when present), for both reactive (inbound activity) and proactive (ContinueConversationAsync) turns.
Changes:
- Plumbs
BotRequestContextintoCompatUserTokenClientandCompatConversationscalls, and sets shared request context inTeamsBotFrameworkHttpAdapter. - Updates
TeamsBotAdaptersend path to pass request context intoConversationClient.SendActivityAsync. - Adds/updates unit tests covering request-context propagation for user token, conversation update, and adapter send/continue flows.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/CompatUserTokenClientTests.cs | Adds unit coverage verifying CompatUserTokenClient forwards BotRequestContext to core UserTokenClient. |
| core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/CompatConversationsTests.cs | Adds test ensuring CompatConversations.UpdateActivityWithHttpMessagesAsync passes RequestContext. |
| core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/CompatBotAdapterTests.cs | Tightens assertion to validate BotRequestContext content is passed on send. |
| core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/CompatAdapterTests.cs | Adds proactive-turn coverage ensuring turn-state UserTokenClient uses the proactive BotRequestContext. |
| core/src/Microsoft.Teams.Apps.BotBuilder/TeamsBotFrameworkHttpAdapter.cs | Creates one inbound/proactive BotRequestContext and shares it across compat clients per turn. |
| core/src/Microsoft.Teams.Apps.BotBuilder/TeamsBotAdapter.cs | Passes request context through the adapter send path into ConversationClient. |
| core/src/Microsoft.Teams.Apps.BotBuilder/CompatUserTokenClient.cs | Adds RequestContext property and forwards it into all core user-token calls. |
| core/src/Microsoft.Teams.Apps.BotBuilder/CompatConversations.cs | Forwards RequestContext into update-activity call to core conversation client. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pass full BotRequestContext through BotBuilder TeamsApiClient calls so bot app id is preserved alongside agentic identity. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Looks good ! Related to the previous PR - #591 can we remove the non BotRequestContext overloads, since it is an optional param anyway |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@MehakBindra addressed this in 402f3ad. I removed the redundant non-BotRequestContext overloads from UserTokenClient and made the requestContext parameters optional on the remaining methods. I also updated the internal wrappers/tests to use named cancellationToken arguments where positional calls would otherwise bind to requestContext. |
Summary
BotRequestContextthroughCompatUserTokenClientto all core user token calls.Validation
dotnet test core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/Microsoft.Teams.Apps.BotBuilder.UnitTests.csproj --no-restore