microsoft / botbuilder-dotnet

Welcome to the Bot Framework SDK for .NET repository, which is the home for the libraries and packages that enable developers to build sophisticated bot applications using .NET.
https://github.com/Microsoft/botframework
MIT License
873 stars 483 forks source link

MultiLanguageRecognizer - Recognizers dictionary does not use case-insensitive key comparer #5479

Closed peterinnesmsft closed 3 years ago

peterinnesmsft commented 3 years ago

Version

4.13.0-rc4

Describe the bug

Multi-language recognizer is unable to select the corresponding recognizer for a given locale if there is a case mismatch between the recognizer locale key and either the locale in the incoming activity or the default locale from the LanguagePolicy.

To Reproduce

Steps to reproduce the behavior:

  1. Using the latest Composer nightly build, create a new Conversational Core bot.
  2. Provision required resources in Azure, including LUIS.
  3. Publish bot to Azure.
  4. Start a conversation with the bot.

Expected behavior

Expected behavior:

Screenshots

Actual behavior:

Additional context

Related to https://github.com/microsoft/BotFramework-Composer/issues/6893.

When creating a new bot on the adaptive runtime, the bot is created using a default locale of 'en-US', which is fed in to the ConfigurationLanguagePolicy. This language policy is ultimately referenced in MultiLanguageRecognizer.

If no locale is explicitly set, we are able to correctly find the language policy corresponding to en-US. However, per ConversationalCore.lu.dialog scaffolded in recognizers dir for new bot, the locale is configured as 'en-us'. When attempting to select the recognizer based on the language policy locale value, it is not discovered because the recognizers dictionary is deserialized into a dictionary that uses a case-sensitive key comparer.

peterinnesmsft commented 3 years ago

Contents of recognizer\CoinversationalCore.lu.dialog for reference:

{
  "$kind": "Microsoft.MultiLanguageRecognizer",
  "id": "LUIS_ConversationalCore",
  "recognizers": {
    "en-us": "ConversationalCore.en-us.lu",
    "": "ConversationalCore.en-us.lu"
  }
}