Ejemplo n.º 1
0
        private async Task <DialogTurnResult> GetFundNameStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var documentModel = (FundDocumentModel)stepContext.Values[FundDocumentModelValue];

            //if no fund is needed
            if (!((bool)stepContext.Result))
            {
                return(await stepContext.NextAsync(null, cancellationToken));
            }

            //generate choices with the list of funds
            var SuggestedActions = SuggestedActionGenerator.GenerateSuggestedActions(Common.PIFundNames);
            var reply            = MessageFactory.Text(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, $"Which fund would you like to see the {documentModel.FundDocument} for?"));

            reply.SuggestedActions = SuggestedActions;

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

            retryReply.SuggestedActions = SuggestedActions;

            //ask for fund name
            return(await stepContext.PromptAsync($"{nameof(FundDocumentsDialog)}.askFundName", new PromptOptions
            {
                Prompt = reply,
                RetryPrompt = retryReply
            }, cancellationToken));
        }
        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 async Task <DialogTurnResult> ParseGivenParametersAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var luisResult = (LuisResult)stepContext.Options;

            var sectorModel = new FundSectorWeightsModel();

            sectorModel.Funds = new List <string>();

            //find fund names and sector
            GetEntityResolutions(luisResult, sectorModel);

            stepContext.Values[FundSectorModelValue] = sectorModel;


            //if no sector was given
            if (string.IsNullOrEmpty(sectorModel.Sector))
            {
                await stepContext.Context.SendActivityAsync(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, "Please select a valid sector to view weighting information"));

                return(await stepContext.EndDialogAsync(null, cancellationToken));
            }
            //if no funds were given, prompt the user to select a fund.
            else if (sectorModel.Funds.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 " +
                                                                                             $"{CultureInfo.InvariantCulture.TextInfo.ToTitleCase(sectorModel.Sector)} sector weightings 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(FundSectorWeightsDialog)}.fundName", new PromptOptions
                {
                    Prompt = reply,
                    RetryPrompt = retryReply
                }, cancellationToken));
            }

            return(await stepContext.NextAsync(null, cancellationToken));
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        private async Task <DialogTurnResult> ParseGivenParametersAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var luisResult       = (LuisResult)stepContext.Options;
            var attributionModel = new FundAttributionModel();

            //find all entities found by LUIS and save it to the model
            GetEntityResolutions(luisResult, attributionModel);

            //if the user requested "any fund"
            if (attributionModel.FundName == "any fund")
            {
                attributionModel.FundName = null;
                await stepContext.Context.SendActivityAsync(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, "You must select a fund to view top contributors/detractors"));

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

            stepContext.Values[FundAttributionModelValue] = attributionModel;

            //if no fund name is given, we need to ask the user
            if (string.IsNullOrEmpty(attributionModel.FundName))
            {
                var choices          = Common.PIFundNames.ToList();
                var suggestedActions = SuggestedActionGenerator.GenerateSuggestedActions(choices);

                var placeholder = attributionModel.ContributorsOrDetractors == 0 ? "top contributors" : "top detractors";

                var reply      = MessageFactory.Text(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, $"Which fund would you like to see {placeholder} 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(FundAttributionDialog)}.fundName", new PromptOptions
                {
                    Prompt = reply,
                    RetryPrompt = retryReply
                }, cancellationToken));
            }

            return(await stepContext.NextAsync(null, cancellationToken));
        }