/// <summary> /// Validates the response from the choice prompt /// </summary> /// <param name="promptContext">The context of the prompt</param> /// <param name="cancellationToken">The cancellation token</param> /// <returns></returns> private async Task <bool> ChoiceValidation(PromptValidatorContext <FoundChoice> promptContext, CancellationToken cancellationToken) { Companies value; if (recognizer != null && recognizer.IsConfigured) { await SendTypingAsync(promptContext.Context, cancellationToken); CareerAdvise luisResult = await recognizer.RecognizeAsync <CareerAdvise>(promptContext.Context, cancellationToken); value = luisResult.Organization; } else { var val = promptContext.Context.Activity.Text; if (!Enum.TryParse(val, true, out value)) { value = Companies.NotSupported; } } switch (value) { case Companies.KPMG: case Companies.Deloitte: case Companies.EY: case Companies.PWC: promptContext.Recognized.Value = CreateChoice(value.ToString()); return(await Task.FromResult(true)); default: return(await Task.FromResult(false)); } }
/// <summary> /// Validates the response from the choice prompt /// </summary> /// <param name="promptContext">The context of the prompt</param> /// <param name="cancellationToken">The cancellation token</param> /// <returns></returns> private async Task <bool> ChoiceValidation(PromptValidatorContext <FoundChoice> promptContext, CancellationToken cancellationToken) { bool result = false; string value = null; if (recognizer != null && recognizer.IsConfigured) { CareerAdvise luisResult = await recognizer.RecognizeAsync <CareerAdvise>(promptContext.Context, cancellationToken); value = luisResult.QuestionType; switch (value?.ToLowerInvariant()) { case "general": case "application": case "assessment": case "interviews": case "offer": case "starting": result = true; break; } } else { // Without LUIS, we need to list all the acceptable answers from user value = promptContext.Context.Activity.Text; switch (value.ToLowerInvariant()) { case "general questions": value = "general"; result = true; break; case "applying": value = "application"; result = true; break; case "assessment test": value = "assessment"; result = true; break; case "interviews": value = "interviews"; result = true; break; case "the offer stage": value = "offer"; result = true; break; case "starting new job": value = "starting"; result = true; break; } } promptContext.Recognized.Value = CreateChoice(value); return(await Task.FromResult(result)); }