//get all the LUIS recognized entities. private void GetEntityModelResolution(LuisResult luisResult, FundHoldingsModel holdingModel) { var entities = luisResult.ConnectedServiceResult.Entities; if (entities != null) { foreach (EntityModel entity in entities) { switch (entity.Type) { case FundName: var fund = Common.GetResolutionFromEntity(entity); if (fund == "any fund") { holdingModel.AllFunds = true; holdingModel.FundName.Add(fund); } else if (fund.Trim().Length == 5) { //is a fund ticker holdingModel.FundName.Add(Common.tickersToFundName[fund.Trim().ToUpper()]); } else { holdingModel.FundName.Add(fund); } break; case CompanyName: holdingModel.Company = entity.Entity; break; //found a holding attribute. i.e. # of shares or Market value. case HoldingAttribute: holdingModel.HoldingAttributes.Add(Common.GetResolutionFromEntity(entity)); break; default: break; } } } }
private async Task <DialogTurnResult> ParseGivenParametersAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var luisResult = (LuisResult)stepContext.Options; var holdingModel = new FundHoldingsModel(); holdingModel.HoldingAttributes = new List <string>(); holdingModel.FundName = new List <string>(); //get the fund names, company, and (optional) holding attributes requested GetEntityModelResolution(luisResult, holdingModel); stepContext.Values[FundHoldingModelValue] = holdingModel; // no company was recognized if (string.IsNullOrEmpty(holdingModel.Company)) { await stepContext.Context.SendActivityAsync(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, "Please specify a company to see holding information.")); return(await stepContext.EndDialogAsync(null, cancellationToken)); } //if no funds were selected, prompt user to select a fund or select all funds. else if (holdingModel.FundName.Count == 0) { var choices = Common.PIFundNames.ToList(); choices.Insert(0, "All funds"); var suggestedActions = SuggestedActionGenerator.GenerateSuggestedActions(choices); var reply = MessageFactory.Text(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, "Which fund would you like to see holding information for?")); var retryReply = MessageFactory.Text(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, "Please select a valid choice")); reply.SuggestedActions = suggestedActions; retryReply.SuggestedActions = suggestedActions; return(await stepContext.PromptAsync($"{nameof(FundHoldingsDialog)}.fundName", new PromptOptions { Prompt = reply, RetryPrompt = retryReply }, cancellationToken)); } return(await stepContext.NextAsync(null, cancellationToken)); }