Skip to content

Commit

Permalink
Merge pull request #3777 from microsoft/tomlm/turnRecognizedScore
Browse files Browse the repository at this point in the history
set recognized properties even if interruption is off
  • Loading branch information
Tom Laird-McConnell committed Apr 22, 2020
2 parents b189697 + 3c5a762 commit 9c2c2c0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/AdaptiveDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ protected override async Task<bool> OnPostBubbleEventAsync(DialogContext dc, Dia
// we have received a RecognizedIntent event
// get the value and promote to turn.recognized, topintent,topscore and lastintent
var recognizedResult = actionContext.State.GetValue<RecognizerResult>($"{TurnPath.DialogEvent}.value");

// #3572 set these here too (Even though the emitter may have set them) because this event can be emitted by declarative code.
var (name, score) = recognizedResult.GetTopScoringIntent();
actionContext.State.SetValue(TurnPath.Recognized, recognizedResult);
actionContext.State.SetValue(TurnPath.TopIntent, name);
Expand Down Expand Up @@ -431,10 +433,16 @@ protected override async Task<bool> OnPostBubbleEventAsync(DialogContext dc, Dia
if (activity.Type == ActivityTypes.Message)
{
// Recognize utterance
var recognized = await OnRecognize(actionContext, activity, cancellationToken).ConfigureAwait(false);
var recognizedResult = await OnRecognize(actionContext, activity, cancellationToken).ConfigureAwait(false);

// TODO figure out way to not use turn state to pass this value back to caller.
actionContext.State.SetValue(TurnPath.Recognized, recognized);
actionContext.State.SetValue(TurnPath.Recognized, recognizedResult);

// Bug #3572 set these here, because if allowedInterruption is true then event is not emitted, but folks still want the value.
var (name, score) = recognizedResult.GetTopScoringIntent();
actionContext.State.SetValue(TurnPath.TopIntent, name);
actionContext.State.SetValue(TurnPath.TopScore, score);
actionContext.State.SetValue(DialogPath.LastIntent, name);

if (Recognizer != null)
{
Expand Down

0 comments on commit 9c2c2c0

Please sign in to comment.