Use Agentforce for Quick Access to Data in Salesforce and Data Cloud | How I Solved It

By

Welcome to another “How I Solved It.” In this series, we do a deep dive into a specific business problem and share how one Awesome Admin chose to solve it. Once you learn how they solved their specific problem, you’ll be inspired to try their solution yourself! Watch how Team Code Cortex built an asset management agent using Agentforce to provide their reps with quick access to critical real-time financial insights from Salesforce and external third-party sources via Data Cloud, enabling them to make informed decisions efficiently.


Key business problem

A fictional financial services company called Code Cortex Asset Management needed an asset management agent. Their reps required quick access to critical real-time financial insights from both Salesforce and external third-party sources. They also needed a way to ask for data from Salesforce, such as fund positions and sales figures, and integrate this information with information from sources like Morningstar and Bloomberg through Data Cloud for performance metrics and market events. This way, they could empower sales teams and managers to make informed decisions efficiently.

How I solved it

The Code Cortex team, made up of Benoy Jose, Mandy Wang, and myself, created an employee agent using Agentforce. Here’s how.

In Agent Builder, I created a new topic. The “General CRM + Asset Mgmt” topic has a classification description, scope, and at least one instruction.

Configuring the topic in Agent Builder.

I gave the prompt, “List all the firms with AUM greater than 100 million in the high yield fund.” The agent returns the firm name as 401K Consults with three other attributes from the Account object. The agent selected the General CRM + Asset Mgmt topic (with 15 instructions and 11 actions) and invoked the custom flow agent action called Get Accounts by Funds.

The prompt we ask the agent, using the General CRM + Asset Mgmt topic and invoked Get Accounts by Fund action.

The Get Accounts By Fund flow is an autolaunched flow. I first use a (1) Get Records element called Get Portfolio by Fund, where we are getting the portfolio by fund from the Portfolio object in Salesforce. Based on what I found in the Get Records element, I’m going to then (2) assign the information to a variable called portfolioRecord using an Assignment element.

Get Accounts By Fund flow.

If I expand the Get Records element, I’m passing two input parameters. The first input parameter is AUM, which the agent passed to the flow as 100 million. The important thing to know about a flow agent action is that any data passed from the agent into our flow needs to be set as Available for input, since the data is coming from outside our flow.

AUM as Input parameter, which has been received from the prompt and passed to the autolaunched flow; for example, 100 M.

Our second input parameter is fundName, that the agent passed as PGIM high yield fund. Since the information is being passed from outside our flow, the key here is to set the Availability Outside the Flow to Available for input.

undName as Input parameter, which has been received from the prompt and passed to the autolaunched flow; for example, High Yield Fund.

Our last variable is called portfolioRecord, which I used in an Assignment element. I set the Availability Outside the Flow for this record variable to Available for output.

portfolioRecord as Output parameter, which displays as result from the agent; for example, 401K Consults.

For my prompt “Give me the fund performance for the ticker for High Yield Fund”, the agent returns the 1 Year Performance, 3 Year Performance, and 5 Year performance for requested ticker. The agent selected the Retrieve Fund Performance from Data Cloud topic (with six instructions and one action) and invoked the custom flow action calledFund Performance.

The prompt we ask the agent, using the Retrieve Fund Performance from Data Cloud topic and invoked Fund performance action.

Let’s review the autolaunched flow called Fund performance, where the agent passed the ticker into the flow and the flow returned the Morningstar fund performance information from the Fund Performance object in Data Cloud.

Here, I use a Get Records element using the ticker as input. We know there is only one record with the ticker, so we stop at the first record found. We store output in separate variables for 1 Year Performance, 3 Year Performance, 5 Year Performance, and corresponding Morningstar rating.

Fund Performance Autolaunched flow.

If you look at the variable declaration in the flow, I have set Ticker (Ticker) as input variable and 1 Year Performance (Yr1Performance), 1 Year Performance (Yr1Performance), 1 Year Performance (Yr1Performance), and Morningstar rating (MorningstarRating) as output variables.

In the flow, Ticker as input and Morningstar Rating, 1 year performance, 3 year performance, and 5 year performance as output variables.

Now, for my prompt, “Get my account holding funds with Morningstar ratings less than 3 stars”, the agent selects the General CRM + Asset Mgmt topic and invokes the custom flow action “Get accounts from funds lower than the specified rating”. The agent passes the low rating of 3 into the flow and it retrieves the collection of accounts; for example, Wells Fargo advisors and 401K Consults.

The prompt we ask the agent, using the General CRM + Asset Mgmt topic and invoked Get Account with funds lower than the specified rating action.

Let’s review the “Get Account with funds lower than the specified rating” autolaunched flow invoked by the agent.

  1. We start with the Get Records element on the Fund Performance object, which is in Data Cloud. We’re looking for all records with a Morningstar rating that's less than the LowRating variable, which, in our case, is three. For each record found, we store the Morningstar Rating and the Product ID.
  2. Then, we loop through all the records found in the Get Records element.
  3. For each item in the loop, we assign the productID to a collection called ProductIDs.
  4. From there, we perform another Get Records element, but this time, on a Salesforce object called Portfolio. We’re looking for a FundId that’s in the collection ProductIDs, from my previous step.
  5. Next, we loop through all the records found in previous Get Records.
  6. For each record in the loop, we take the AccountId and add it to a CollectionOfAccountIDs collection variable.
  7. Lastly, we do a final Get Records on the Account object in Salesforce, where we’re looking for all accounts where the ID is in the CollectionOfAccountIDs. We store the records found in a new variable called CollectionofAccounts, storing specifically the ID and Account Name.

Get Account with funds lower than the specified rating autolaunched flow.

For the CollectionofAccounts variable, I set the Availability Outside the Flow to Available for output, which means Flow will make the data available to the agent. Back to Agent Builder, my next prompt is to create opportunities with the information where the name is Hackathon 24, stage is ‘Qualification,’ and close date is 15 days from now.

In response, the agent selected the General CRM + Asset Mgmt topic and invoked the custom flow action Create Multiple Opportunities, sending the AccountIDs for Wells Fargo advisors and 401K Consults into the flow.

The prompt we ask to the agent; using the General CRM + Asset Mgmt topic and invoked Create Multiple Opportunities action.

Now, let’s review the Create Multiple Opportunities autolaunched flow.

  1. We use a Decision element to check whether our account list has accounts or not.
  2. Then, we loop through each account found.
  3. For each record in the loop, we assign opportunity values with the name of Hackathon 24, the stage as Qualification, and the CloseDate formula, which sets it to 15 days from today's date, and AccountId from the AccountIdList collection variable from the previous step.
  4. Finally, we will create an Opportunity record using the Opportunity record assignment from the previous step.

Create Multiple Opportunities autolaunched flow.

Business results

We utilized prompt engineering and flows to efficiently retrieve less commonly used data with minimal effort for users. By hosting external industry data in Data Cloud, we helped users seamlessly combine it with Salesforce data. Additionally, we developed a simple interface that allows users to have natural conversations with the agent and quickly obtain answers.

Do try this at home

To get started, hit the trail and navigate to Get Ready for Agentforce on Trailhead to learn how Agentforce fits into your business goals, launch your first agent, and build a plan for artificial intelligence (AI) success. Create a playground—start building and configuring Agentforce with topics, custom actions, and instructions. Try searching for data in a Salesforce objects and get results. Fine-tune your prompts with multiple instructions that can handle the different types of questions users could ask. Here are a few use cases to try.

  1. Find all contacts that have a specific attribute like ‘region’, ‘support tier’, ‘sales numbers’, etc.
  2. Show contacts that match multiple attributes at the same time.
  3. Use flows to combine multiple data points and use them as part of the prompt.

Resources

Want to see more good stuff? Subscribe to our channel!

SUBSCRIBE TODAY
Introducing Data Cloud governance

Data Cloud Governance: Protecting Your Data in the Agentic Landscape

What is Data Cloud Governance? As a Salesforce Admin, you’re the backbone of your organization’s data management. You make sure everyone has the right data at the right time to do their jobs efficiently, while keeping everything secure, compliant, and running smoothly. But as we move into an agent-driven future, the workplace is evolving. Employees […]

READ MORE
Protect data With Private Connect for Data Cloud

Enhance Agentforce Data Security With Private Connect for Data Cloud

In today’s digital landscape, ensuring the security of customer data is one of the top priorities for Salesforce Admins. With the increasing frequency of security breaches, the need for robust protection of sensitive information is more critical than ever. Exposing services to the public internet inherently opens up vulnerabilities that can lead to unauthorized access, […]

READ MORE