/// <summary> /// Called when input has been received, recognizes choice. /// </summary> /// <param name="dc">The <see cref="DialogContext"/> for the current turn of conversation.</param> /// <param name="cancellationToken">Optional, the <see cref="CancellationToken"/> that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>InputState which reflects whether input was recognized as valid or not.</returns> protected override Task <InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken = default) { var input = dc.State.GetValue <object>(VALUE_PROPERTY); var options = dc.State.GetValue <ChoiceInputOptions>(ThisPath.Options); var choices = options.Choices; if (dc.Context.Activity.Type == ActivityTypes.Message) { var opt = RecognizerOptions?.GetValue(dc.State) ?? new FindChoicesOptions(); opt.Locale = DetermineCulture(dc, opt); var results = ChoiceRecognizers.RecognizeChoices(input.ToString(), choices, opt); if (results == null || results.Count == 0) { return(Task.FromResult(InputState.Unrecognized)); } var foundChoice = results[0].Resolution; switch (OutputFormat.GetValue(dc.State)) { case ChoiceOutputFormat.Value: default: dc.State.SetValue(VALUE_PROPERTY, foundChoice.Value); break; case ChoiceOutputFormat.Index: dc.State.SetValue(VALUE_PROPERTY, foundChoice.Index); break; } } return(Task.FromResult(InputState.Valid)); }