Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,50 @@
/build/** @microsoft/bb-dotnet

# Specific Test Projects
/tests/Microsoft.Bot.Builder.TestBot.Json/** @chrimc62 @tomlm @microsoft/bf-adaptive
/tests/Microsoft.Bot.Builder.TestBot.Json/** @chrimc62 @tomlm @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/tests/Microsoft.Bot.Builder.TestProtocol/** @gabog @microsoft/bf-skills

# Adapters
/libraries/Adapters/** @garypretty @mrivera-ms
/tests/Adapters/** @garypretty @mrivera-ms
/libraries/Adapters/** @EricDahlvang @garypretty @mrivera-ms
/tests/Adapters/** @EricDahlvang @garypretty @mrivera-ms

# Platform Integration Libaries (.NET Core and WebApi)
/libraries/integration/** @microsoft/bb-dotnet-integration
/tests/integration/** @microsoft/bb-dotnet-integration

# Application Insights/Telemetry
/libraries/Microsoft.Bot.Builder.ApplicationInsights/** @garypretty @mrivera-ms
/tests/Microsoft.Bot.Builder.ApplicationInsights.Tests/** @garypretty @mrivera-ms
/libraries/Microsoft.Bot.Builder.ApplicationInsights/** @EricDahlvang @johnataylor @mrivera-ms
/tests/Microsoft.Bot.Builder.ApplicationInsights.Tests/** @EricDahlvang @johnataylor @mrivera-ms

# AI: LUIS + Orchestrator
/libraries/Microsoft.Bot.Builder.AI*/** @microsoft/bf-cog-services
/tests/Microsoft.Bot.Builder.AI*/** @microsoft/bf-cog-services

# AI: QnA Maker
/libraries/Microsoft.Bot.Builder.AI.QnA/** @mrivera-ms @microsoft/bf-cog-services
/tests/Microsoft.Bot.Builder.AI.QnA.Tests/** @mrivera-ms @microsoft/bf-cog-services
/libraries/Microsoft.Bot.Builder.AI.QnA/** @mrivera-ms @microsoft/bf-cog-services
/tests/Microsoft.Bot.Builder.AI.QnA.Tests/** @mrivera-ms @microsoft/bf-cog-services

# Azure (Storage)
/libraries/Microsoft.Bot.Builder.Azure/** @EricDahlvang @mrivera-ms
/tests/Microsoft.Bot.Builder.Azure.Tests/** @EricDahlvang @mrivera-ms

# Adaptive Dialogs
/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/** @microsoft/bf-adaptive
/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive.Teams/** @microsoft/bf-adaptive
/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive.Testing/** @microsoft/bf-adaptive
/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive.Teams/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive.Testing/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
# Adaptive Dialogs' tests
/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling/** @microsoft/bf-adaptive
/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Teams.Tests/** @microsoft/bf-adaptive
/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Templates.Tests/** @microsoft/bf-adaptive
/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/** @microsoft/bf-adaptive
/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Teams.Tests/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Templates.Tests/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms

# AdaptiveExpressions & LanguageGeneration libraries
/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/** @microsoft/bf-adaptive
/tests/Microsoft.Bot.Builder.Dialogs.Declarative.Tests/** @microsoft/bf-adaptive
/libraries/Microsoft.Bot.Builder.LanguageGeneration/** @microsoft/bf-adaptive
/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/** @microsoft/bf-adaptive
/libraries/AdaptiveExpressions/** @microsoft/bf-adaptive
/tests/AdaptiveExpressions.Tests/** @microsoft/bf-adaptive
/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/tests/Microsoft.Bot.Builder.Dialogs.Declarative.Tests/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/libraries/Microsoft.Bot.Builder.LanguageGeneration/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/libraries/AdaptiveExpressions/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms
/tests/AdaptiveExpressions.Tests/** @microsoft/bf-adaptive @EricDahlvang @mrivera-ms

# BotBuilder Dialogs Debugging
/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/** @mrivera-ms @tomlm @gabog
Expand All @@ -74,29 +74,30 @@
/tests/Microsoft.Bot.Builder.TemplateManager/** @mrivera-ms @tomlm

# BotBuilder Testing
/libraries/Microsoft.Bot.Builder.Testing/** @gabog
/tests/Microsoft.Bot.Builder.Testing.Tests/** @gabog
/libraries/Microsoft.Bot.Builder.Testing/** @gabog @EricDahlvang
/tests/Microsoft.Bot.Builder.Testing.Tests/** @gabog @EricDahlvang

# Bot Framework Schema
/libraries/Microsoft.Bot.Schema/** @mrivera-ms @johnataylor
/tests/Microsoft.Bot.Schema.Tests/** @mrivera-ms @johnataylor
/libraries/Microsoft.Bot.Schema/** @microsoft/bb-core
/tests/Microsoft.Bot.Schema.Tests/** @microsoft/bb-core

# Streaming library
/libraries/Microsoft.Bot.Builder/Streaming/** @microsoft/bf-streaming
/libraries/Microsoft.Bot.Streaming/** @microsoft/bf-streaming
/tests/Microsoft.Bot.Builder.Streaming.Tests/** @microsoft/bf-streaming
/tests/Microsoft.Bot.Streaming.Tests/** @microsoft/bf-streaming

# BotBuilder library
/libraries/Microsoft.Bot.Builder/** @gabog @johnataylor
/tests/Microsoft.Bot.Builder.Tests/** @gabog @johnataylor
/libraries/Microsoft.Bot.Builder/** @microsoft/bb-core
/tests/Microsoft.Bot.Builder.Tests/** @microsoft/bb-core

# BotBuilder Dialogs
/libraries/Microsoft.Bot.Builder.Dialogs/** @microsoft/bf-dialogs
/tests/Microsoft.Bot.Builder.Dialogs/** @microsoft/bf-dialogs

# Bot Framework Connector
/libraries/Microsoft.Bot.Connector/** @mrivera-ms @carlosscastro @johnataylor
/tests/Microsoft.Bot.Connector.Tests/** @mrivera-ms @carlosscastro @johnataylor
/libraries/Microsoft.Bot.Connector/** @microsoft/bb-core
/tests/Microsoft.Bot.Connector.Tests/** @microsoft/bb-core

# Bot Framework Authentication
/libraries/Microsoft.Bot.Builder/OAuth/** @microsoft/bf-auth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Generic;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Collections.Generic;

namespace Microsoft.Bot.Builder
{
Expand Down
3 changes: 2 additions & 1 deletion libraries/Microsoft.Bot.Builder/IntentScore.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Collections.Generic;
using Newtonsoft.Json;

Expand Down
5 changes: 4 additions & 1 deletion libraries/Microsoft.Bot.Builder/RegisterClassMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Threading;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.Bot.Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -116,19 +119,31 @@ public async Task<InvokeResponse> ProcessStreamingActivityAsync(Activity activit
BotAssert.ActivityNotNull(activity);

Logger.LogInformation($"Received an incoming streaming activity. ActivityId: {activity.Id}");

// If a StreamingRequestHandler.Audience is a null value, then no callerId should have been generated
// and GetAudienceFromCallerId returns null.
// Thus we fallback to relying on the "original key", essentially $"{ServiceUrl}{Conversation.Id}",
// as opposed to $"{ServiceUrl}{Audience}{Conversation.Id}" and the StreamingRequestHandler implicitly does not support skills.
var audience = GetAudienceFromCallerId(activity);

// If a conversation has moved from one connection to another for the same Channel or Skill and
// hasn't been forgotten by the previous StreamingRequestHandler. The last requestHandler
// the conversation has been associated with should always be the active connection.
var requestHandler = RequestHandlers.Where(x => x.ServiceUrl == activity.ServiceUrl).Where(y => y.HasConversation(activity.Conversation.Id)).LastOrDefault();
var requestHandler = RequestHandlers.Where(
h => h.ServiceUrl == activity.ServiceUrl
&& h.Audience == audience
&& h.HasConversation(activity.Conversation.Id))
.LastOrDefault();
using (var context = new TurnContext(this, activity))
{
context.TurnState.Add<string>(OAuthScopeKey, audience);

// Pipes are unauthenticated. Pending to check that we are in pipes right now. Do not merge to master without that.
if (ClaimsIdentity != null)
{
context.TurnState.Add<IIdentity>(BotIdentityKey, ClaimsIdentity);
}

var connectorClient = CreateStreamingConnectorClient(activity, requestHandler);
context.TurnState.Add(connectorClient);

Expand Down Expand Up @@ -217,9 +232,10 @@ public async Task<ResourceResponse> SendStreamingActivityAsync(Activity activity
/// </summary>
/// <param name="pipeName">The name of the Named Pipe to connect to.</param>
/// <param name="bot">The bot to use when processing activities received over the Named Pipe.</param>
/// <param name="audience">The specified recipient of all outgoing activities.</param>
/// <returns>A task that completes only once the StreamingRequestHandler has stopped listening
/// for incoming requests on the Named Pipe.</returns>
public async Task ConnectNamedPipeAsync(string pipeName, IBot bot)
public async Task ConnectNamedPipeAsync(string pipeName, IBot bot, string audience = null)
{
if (string.IsNullOrEmpty(pipeName))
{
Expand All @@ -234,7 +250,7 @@ public async Task ConnectNamedPipeAsync(string pipeName, IBot bot)
RequestHandlers = new List<StreamingRequestHandler>();
}

var requestHandler = new StreamingRequestHandler(bot, this, pipeName, Logger);
var requestHandler = new StreamingRequestHandler(bot, this, pipeName, audience, Logger);
RequestHandlers.Add(requestHandler);

await requestHandler.ListenAsync().ConfigureAwait(false);
Expand Down Expand Up @@ -295,5 +311,27 @@ private IConnectorClient CreateStreamingConnectorClient(Activity activity, Strea
var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl), emptyCredentials, customHttpClient: streamingClient);
return connectorClient;
}

/// <summary>
/// Attempts to get an audience from the <see cref="Activity.CallerId"/>.
/// </summary>
/// <param name="activity">The incoming activity to be processed by a <see cref="StreamingRequestHandler"/>.</param>
private string GetAudienceFromCallerId(Activity activity)
{
switch (activity.CallerId)
{
case CallerIdConstants.PublicAzureChannel:
return AuthenticationConstants.ToChannelFromBotOAuthScope;
case CallerIdConstants.USGovChannel:
return GovernmentAuthenticationConstants.ToChannelFromBotOAuthScope;
default:
if (activity.CallerId.StartsWith(CallerIdConstants.BotToBotPrefix, StringComparison.InvariantCultureIgnoreCase))
{
return activity.CallerId.Substring(CallerIdConstants.BotToBotPrefix.Length);
}

return null;
}
}
}
}
Loading