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)); }
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)); }
private async Task <DialogTurnResult> DispatchIraAccountDocumentAsync(WaterfallStepContext stepContext, AccountDocumentModel documentModel, CancellationToken cancellationToken) { //if no document was specified for the account, lead the user to the general documents page if (string.IsNullOrEmpty(documentModel.AccountDocument)) { var link = ChannelFormattingService.FormatLinkMessageAndSaveToState(stepContext.Context, Common.PIIraDocumentUrl, _botService, cancellationToken); await stepContext.Context.SendActivityAsync(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, $"You can view all Ira-Related Account documents by clicking {link}. " + $"You can also ask for a specific document in the same fashion and I can direct you right to it.")); } //if document was originally specified else { //get the URL and respond. var link = ChannelFormattingService.FormatLinkMessageAndSaveToState(stepContext.Context, APIService.GetAccountDocumentURL(documentModel), _botService, cancellationToken); await stepContext.Context.SendActivityAsync(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, $"You can view the IRA {documentModel.AccountDocument} document by clicking {link}")); } return(await stepContext.NextAsync(null, cancellationToken)); }
private async Task <DialogTurnResult> DispatchNonIraAccountDocumentAsync(WaterfallStepContext stepContext, AccountDocumentModel documentModel, CancellationToken cancellationToken) { var sendGeneralUrl = false; //if the user requested a Standard acct transfer form. if (Common.IraOnlyDocumentTypes.Contains(documentModel.AccountDocument)) { await stepContext.Context.SendActivityAsync(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, $"Sorry, there is currently not a {documentModel.AccountDocument} document/form for Standard accounts.")); sendGeneralUrl = true; } //the user requested a specific document, find the URL and respond. else if (!string.IsNullOrEmpty(documentModel.AccountDocument)) { var link = ChannelFormattingService.FormatLinkMessageAndSaveToState(stepContext.Context, APIService.GetAccountDocumentURL(documentModel), _botService, cancellationToken); await stepContext.Context.SendActivityAsync(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, $"You can view the Standard {documentModel.AccountDocument} " + $"document by clicking {link}")); } else { sendGeneralUrl = true; } //if the user did not specify a document, or the user requested a standard acct. transfer form, lead them to the general document page. if (sendGeneralUrl) { var link = ChannelFormattingService.FormatLinkMessageAndSaveToState(stepContext.Context, Common.PINonIraDocumentUrl, _botService, cancellationToken); await stepContext.Context.SendActivityAsync(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, $"You can view all Standard Account related documents by clicking {link}. " + $"You can also ask for a specific document in the same fashion and I can direct you right to it.")); } return(await stepContext.NextAsync(null, cancellationToken)); }
private async Task <DialogTurnResult> ParseAllGivenInformationStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var luisResult = (LuisResult)stepContext.Options; var documentModel = new AccountDocumentModel { //get ira or standard account type AccountType = GetEntityModelResolution(luisResult, AccountTypeEntity), //get account document AccountDocument = GetEntityModelResolution(luisResult, DocumentTypeEntity) }; documentModel.SetIsIra(); //determines if account is an IRA acct or Standard //if any account type was specified. if (documentModel.IsIra.HasValue) { stepContext.Values[DocumentModelValue] = documentModel; //the account requested is an IRA if (documentModel.IsIra == 1) { return(await DispatchIraAccountDocumentAsync(stepContext, documentModel, cancellationToken)); } //account is standard return(await DispatchNonIraAccountDocumentAsync(stepContext, documentModel, cancellationToken)); } else { //no account has been supplied //if the document specified is an IRA transfer form, but the user did not specify IRA if (Common.IraOnlyDocumentTypes.Contains(documentModel.AccountDocument)) { documentModel.AccountType = "ira"; stepContext.Values[DocumentModelValue] = documentModel; return(await DispatchIraAccountDocumentAsync(stepContext, documentModel, cancellationToken)); } //otherwise, prompt for which account type. var msg = "Which type of account would you like to see "; if (string.IsNullOrEmpty(documentModel.AccountDocument)) { msg += " documents for?"; } else { msg += $" the {documentModel.AccountDocument} application/form for?"; } msg = ChannelFormattingService.FormatSimpleMessage(stepContext.Context, msg); stepContext.Values[DocumentModelValue] = documentModel; return(await stepContext.PromptAsync($"{nameof(AccountDocumentsDialog)}.accountType", new PromptOptions { Prompt = MessageFactory.Text(msg), RetryPrompt = MessageFactory.Text(ChannelFormattingService.FormatSimpleMessage(stepContext.Context, "Please select a valid account type")), Choices = ChoiceFactory.ToChoices(AccountTypeChoices) }, cancellationToken)); } }