private async Task <DialogTurnResult> ParseGivenParametersAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var attrModel  = new FundAttributesModel();
            var luisResult = (LuisResult)stepContext.Options;

            /*find the attribute entity types that were recognized.
             *      i.e. If I send "I want the PARMX expense ratio", this step will
             *      find that the user requested FundBasicAttributeType and save it within the FundAttributesModel
             */
            FindFundNameAndAttributeEntities(attrModel, luisResult);

            //save the model
            stepContext.Values[FundAttributesModelValue] = attrModel;

            //Prompt for fund name by giving a list of choices. This makes it so the user doesn't get prompted with an error if he/she tries to type the fund themselves
            if (string.IsNullOrEmpty(attrModel.PIFundName))
            {
                var SuggestedActions = SuggestedActionGenerator.GenerateSuggestedActions(Common.PIFundNames);
                var reply            = MessageFactory.Text(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, $"Which fund would you like to see your requested attributes for?"));
                reply.SuggestedActions = SuggestedActions;

                var retryReply = MessageFactory.Text(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, $"Please select a valid fund to view its attributes"));
                retryReply.SuggestedActions = SuggestedActions;

                return(await stepContext.PromptAsync($"{nameof(FundSpecificAttributesDialog)}.askFundName", new PromptOptions
                {
                    Prompt = reply,
                    RetryPrompt = retryReply
                }, cancellationToken));
            }

            return(await stepContext.NextAsync(null, cancellationToken));
        }
        private void ParseEntities(FundAttributesModel attrModel, LuisResult luisResult)
        {
            var entityList = attrModel.FundBasicAttributes;

            // find all entities that were detected as Fund Basic attributes
            var entities = luisResult.ConnectedServiceResult.Entities.Where(s => s.Type == EntityType);

            foreach (var entity in entities)
            {
                //get the normalized value
                var value = Common.GetResolutionFromEntity(entity);

                //add to list if it is not there (NEEDED)
                if (!entityList.Contains(value))
                {
                    entityList.Add(value);
                }
            }
        }
        private void FindFundNameAndAttributeEntities(FundAttributesModel attrModel, LuisResult luisResult)
        {
            var attrDict = attrModel.GivenAttributesDictionary;

            foreach (var entity in luisResult.ConnectedServiceResult.Entities)
            {
                //found the fund name given
                if (entity.Type == PIFundName)
                {
                    var fund = Common.GetResolutionFromEntity(entity);

                    //if fund is a ticker
                    if (fund.Trim().Length == 5)
                    {
                        attrModel.PIFundName = Common.tickersToFundName[fund.Trim().ToUpper()];

                        //figure out which type of shares from ticker
                        if (Common.investFundSymbols.Values.Contains(fund.Trim().ToUpper()))
                        {
                            attrModel.PISharesType = 1;
                        }
                        else
                        {
                            attrModel.PISharesType = 2;
                        }
                    }
                    else
                    {
                        attrModel.PIFundName = fund;
                    }
                }
                //found the shares type given
                else if (entity.Type == PIFundSharesType)
                {
                    attrModel.PISharesType = Common.GetResolutionFromEntity(entity) == "investor shares" ? 1 : 2;
                }
                //found an entity type group (i.e. FundBasicAttributeType)
                else if (attrDict.ContainsKey(entity.Type))
                {
                    attrDict[entity.Type] = true;
                }
            }
        }
        private async Task <DialogTurnResult> ParseGivenParametersAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            //get luisResult containing all entities and the attribute model from the options sent from the parent dialog
            LuisResult          luisResult = (LuisResult)((List <object>)stepContext.Options)[0];
            FundAttributesModel attrModel  = (FundAttributesModel)((List <object>)stepContext.Options)[1];

            attrModel.FundBasicAttributes = new List <string>();

            // store recognized entities into the Attribute model
            ParseEntities(attrModel, luisResult);

            //get fund basic attributes requested
            Dictionary <string, Dictionary <string, string> > basicAttributes = await APIService.GetFundBasicsAttributes(attrModel);

            //send response in a subtitle > list format
            var message = ChannelFormattingService.FormatSubtitleAndList(stepContext.Context, basicAttributes);

            await stepContext.Context.SendActivityAsync(message, null, null, cancellationToken);

            return(await stepContext.EndDialogAsync(true, cancellationToken));
        }