Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ protected override Task<PromptRecognizerResult<bool>> OnRecognizeAsync(
}

var culture = DetermineCulture(turnContext.Activity);
var results = ChoiceRecognizer.RecognizeBoolean(utterance, culture);

var results = ChoiceRecognizer.RecognizeBoolean(utterance, options.RecognizeLanguage ?? culture);
if (results.Count > 0)
{
var first = results[0];
Expand Down
10 changes: 10 additions & 0 deletions 10 libraries/Microsoft.Bot.Builder.Dialogs/Prompts/PromptOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,15 @@ public class PromptOptions
/// </summary>
/// <value>Additional options for use with a prompt validator.</value>
public object Validations { get; set; }

/// <summary>
/// Gets or sets the locale used for recognizing the user's choice.
/// </summary>
/// <value>The locale to be use for recognizing the utterance.</value>
/// <remarks>
/// When using a translator middleware, the user's choice is translated and it doesn't match the prompt's options.
/// Setting this property with the translator's target language allows the prompt to recognize the utterance.
/// </remarks>
public string RecognizeLanguage { get; set; }
}
}
57 changes: 57 additions & 0 deletions 57 tests/Microsoft.Bot.Builder.Dialogs.Tests/ConfirmPromptTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,63 @@ public async Task ConfirmPromptChoiceOptionsNoNumbers()
.StartTestAsync();
}

[Fact]
public async Task ConfirmPromptDifferentRecognizeLanguage()
{
var convoState = new ConversationState(new MemoryStorage());
var dialogState = convoState.CreateProperty<DialogState>("dialogState");

var adapter = new TestAdapter(TestAdapter.CreateConversation(nameof(ConfirmPromptDifferentRecognizeLanguage)))
.Use(new AutoSaveStateMiddleware(convoState))
.Use(new TranscriptLoggerMiddleware(new TraceTranscriptLogger(traceActivity: false)));

var dialogs = new DialogSet(dialogState);
var prompt = new ConfirmPrompt("ConfirmPrompt", defaultLocale: Culture.English);

dialogs.Add(prompt);

await new TestFlow(adapter, async (turnContext, cancellationToken) =>
{
var dc = await dialogs.CreateContextAsync(turnContext, cancellationToken);

var results = await dc.ContinueDialogAsync(cancellationToken);
if (results.Status == DialogTurnStatus.Empty)
{
var options = new PromptOptions
{
Prompt = new Activity
{
Type = ActivityTypes.Message,
Text = "Please confirm.",
},
RetryPrompt = new Activity
{
Type = ActivityTypes.Message,
Text = "Please confirm, say 'yes' or 'no' or something like that.",
},
RecognizeLanguage = "es-es"
};
await dc.PromptAsync("ConfirmPrompt", options, cancellationToken);
}
else if (results.Status == DialogTurnStatus.Complete)
{
if ((bool)results.Result)
{
await turnContext.SendActivityAsync(MessageFactory.Text("Confirmed."), cancellationToken);
}
else
{
await turnContext.SendActivityAsync(MessageFactory.Text("Not confirmed."), cancellationToken);
}
}
})
.Send("hola")
.AssertReply("Please confirm. (1) Yes or (2) No")
.Send("si")
.AssertReply("Confirmed.")
.StartTestAsync();
}

[Fact]
public async Task ShouldUsePromptClassStyleProperty()
{
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.