AI is only as good as the context you give it, and that is exactly where grounding comes in. In Salesforce AI, grounding means connecting your AI-generated prompts directly to real, meaningful Salesforce data. Without it, AI responses can sound nice but end up missing the point. They tend to be too generic, disconnected from what is actually happening in your org, and lack the business context that users expect. Grounding fixes this by tying prompts to live records, business logic, and data models, making the AI smarter and far more relevant.
In this article, we will dive into how grounding works inside Salesforce Prompt Builder, why it plays such a critical role, and the different ways you can ground your prompts to build smarter, more helpful AI experiences. If you want your AI to understand your business instead of guessing, grounding is the ingredient you cannot skip.
What Is Grounding, and Why Does It Matter?
Grounding is like giving your AI a home-field advantage. It is how you guide the model by saying: “Here is the real data you need to answer this question properly.” When you ground prompts in Salesforce data, whether that is an Opportunity record, a list of Case comments, or the output of a Flow, you set the AI up to deliver responses that are useful, tailored, and ready for action.
For example, when a user asks to summarize a Case, grounding makes it possible for AI to pull information not just from the Case itself, but also from Case Comments, related records like Entitlements or Assets, and even external data brought in through Data Cloud. As long as everything has been properly configured and grounded in Prompt Builder, the AI can create a much richer, more complete summary without you having to piece it together manually.
Grounding Techniques in Prompt Builder
Salesforce Prompt Builder gives you several ways to ground your prompts, depending on what you need. Each method helps the AI connect to real data and deliver better, more business-ready responses. Let’s take a closer look at the main options.
1. Record Merge Fields
Record Merge Fields let you pull values from a specific record straight into your prompt. They are perfect when you want to personalize the output using details from a single record, like a contact’s name, an account’s industry, or an opportunity’s stage.
You can easily insert these fields by selecting them from the resource picker inside the Prompt Builder editor. It keeps your prompts flexible and saves you from hardcoding details every time.
2. Related List Merge Fields
Related List Merge Fields let you reference collections of related records, like Case Comments, Product Line Items, or Activities, and include them directly in your prompt. This is really useful when you want the AI to understand context like recent interactions, support history, or any connected data tied to the main record.
In Prompt Builder, you can ground your template with an object’s related lists by selecting them from the resource picker. The available fields come from the page layout of the parent object, based on what the current user can see. When you use a related list, the information is passed to the prompt as a JSON structure. For example, if you want to include contacts related to an account, you would select “Related List: Account.Contacts”.
Just keep in mind that very large related lists can make the prompt harder for the model to process.
3. Flow Merge Fields
Flow Merge Fields let you pull in data that has been processed or calculated inside a Flow. This is great when you have custom business logic or dynamic calculations that you want the AI to use in its response.
In Prompt Builder, you can use a Flow Merge Field to connect a Template-Triggered Prompt Flow to your prompt template. Inside the Flow, you can add complex logic and insert prompt instructions using the Add Prompt Instructions element. You can also reference Unified Data Cloud objects by using a Get Records element in the Flow. When you ground a prompt with a Flow, it appears in the template as “Flow: FlowName”. For example, a Flow called “Get_Opportunities_Flow” would be added as “Flow: Get_Opportunities_Flow”.
4. Apex Merge Fields
Apex Merge Fields are the way to go when you need custom backend logic to generate or format data before it reaches the prompt. They are especially useful when you are working with data that needs complex transformations or advanced calculations that are not easy to handle in Flow. This makes them a great choice for things like complex quoting, territory logic, or product bundling scenarios.
In Prompt Builder, you can add an Apex class to a prompt template to handle tasks like running SOQL queries, calling external APIs, generating well-formatted JSON, or applying programmatic data filters. When you ground a prompt with an Apex class, it is added as “Apex: ApexClassName”. For example, a class named “AccountEventsPrompt” would show up as “Apex: AccountEventsPrompt”. Apex grounding opens up a lot of flexibility for advanced use cases where standard tools are not enough.
If an Apex class has been made available for grounding, you will see it listed in the resource picker just like any other option:

5. Data Model Object (DMO) Merge Fields
Data Model Object (DMO) Merge Fields are perfect when you are working with structured data from Salesforce’s Data Cloud. They let you pull in unified profiles or harmonized datasets that bring together information from multiple sources. This is especially useful for creating prompts based on enriched customer profiles, marketing segments, or behavioral data collected across different systems.
In Prompt Builder, you can ground a prompt template with DMOs, which are groupings of data created from streams, insights, and other sources inside Data Cloud. You can use Data Cloud enrichments to build relationships between DMOs and standard Salesforce objects like Contact or Lead. Fields and related lists from these DMOs are available for grounding, making it easy to bring richer, more complete context into your prompts.
6. Record Snapshots
Record Snapshots let you capture and freeze a record’s data at a specific point in time, so you can use it later without worrying about changes. They are really helpful when you want to preserve the state of a record before or after a business event or transaction. This makes them ideal for historical comparisons, version tracking, or workflows that need to meet strict regulatory requirements.
In Prompt Builder, a record snapshot represents a single resource you can use to ground a prompt with the fields that are available on the user’s page layout for an object. For example, you can create a Lead snapshot to ground your prompt with the exact Lead data that was visible to the user at the time a key event happened, like a qualification update. It gives you a reliable way to keep prompts aligned with what the data looked like at an important moment.
7. Retrieval-Augmented Generation (RAG)
Retrieval-Augmented Generation, or RAG, is an advanced technique that allows the model to pull in relevant information from external or large-scale sources before it generates a response. It is a great option when you want to combine Salesforce data with knowledge bases, PDFs, emails, or documents stored outside your CRM. RAG helps bridge the gap between structured Salesforce records and broader enterprise knowledge that lives in other systems.
In Prompt Builder, you can ground prompts with context from unstructured text sources that have been organized in a vector database, like Knowledge articles, chat transcripts, or support emails.
Retrievers can be built and activated through the Einstein Studio. For example, you could set up a retriever that searches your internal support Knowledge base to pull troubleshooting steps for a product issue, then use that information to generate a personalized Case summary. It gives your prompts a much deeper pool of knowledge to pull from without manually copying over details.
Choosing the Right Grounding Method
Each grounding technique plays a different role, and choosing the right one can make a big difference. Here are a few quick tips to help you decide:
- If you want simple personalization, Record Merge Fields are the way to go.
- When you need summaries or prompts that need a lot of context, Related List Merge Fields are your best friend.
- If your logic is dynamic or depends on conditions, Flow or Apex Merge Fields will give you more control.
- When you need to bring in unified profiles or third-party data, DMO Merge Fields or RAG are the best fit.
- If you want to track changes over time, Record Snapshots are your go-to.
No matter which technique you use, always keep performance in mind. Feeding too much data into a prompt can slow down responses or make the output less helpful. It is better to focus on quality over quantity.
Final Thoughts
Grounding is what transforms Salesforce AI from something interesting into a powerful tool. It is the difference between getting a generic answer and getting one that truly understands business, customers, and goals. With the right setup, Prompt Builder can create responses that are meaningful and data-driven.
Choosing the right grounding technique is key. Sometimes you need simple personalization, and other times you need full business context, external knowledge, or complex logic. When you match the right method to the right situation, your prompts become real tools that drive better decisions and stronger business outcomes.
Grounding might seem like a behind-the-scenes step, but it is the foundation for building AI experiences that people trust and rely on. You are making sure AI works smarter for your team, customers, and business. When you invest the time to get grounding right, you open the door to AI solutions that are genuinely helpful, consistent, and successful.