๐ฌ In plain words: An AI model knows absolutely nothing about your specific company. Grounding is how you securely inject real Salesforce facts into the prompt right before the AI answers. There are five ways to do this in Agentforce, ranging from grabbing a simple field to searching a massive Data Cloud document.
⚡ 1-Minute Summary (Key Points)
- There are exactly five ways to ground an AI prompt in Salesforce: Merge Fields, Related Lists, Flow, Apex, and Data Cloud Retrievers.
- When an AI gives a wrong or hallucinated answer, the problem is usually a missing fact, not a weak model. You should always add factual grounding before you try upgrading to a more expensive LLM.
- Security rules always apply! If a user doesn't have Field-Level Security (FLS) access to a grounded field, it doesn't throw an error—it resolves to a silent blank, and the AI will just guess to fill the gap.
๐บ️ Module Map
MODULE 6 root: 'How does the AI agent get real facts?' ├─ 6.1 The five grounding sources ← [ You are here ] ├─ 6.2 Prompt template types and how you write one └─ 6.3 The silent blank (Security & FLS)
๐ The 5 Grounding Sources Explained
To make the AI's output trustworthy, you have to feed it the right data. Here are the five tools in your belt, moving from the simplest to the most advanced:
- 1. Merge Fields: Bring in specific fields from a single record (e.g.,
{!$Input.Account.Name}). This is exact, cheap, and handles structured data perfectly. - 2. Related Lists: Bring in child records attached to the main record. For example, pulling the last six closed cases on a specific meter.
- 3. Flow Grounding: Use a declarative Salesforce Flow to compute a value and inject the result into the prompt.
- 4. Apex Grounding: Use code to run complex logic, aggregate heavy data, or even make an external API callout, passing the final result to the prompt.
- 5. Data Cloud Retriever: Use Semantic Search (RAG) to pull relevant unstructured text out of massive documents stored in Data Cloud (covered deep in Module 7).
๐ Real-Life Example: The Ultimate Billing Prompt
Imagine an agent resolving a customer's billing dispute. The prompt uses all the tools:
• It pulls the customer's current tariff plan via a Merge Field.
• It lists the last six monthly bills using a Related List.
• It calculates their average seasonal consumption using a Flow.
• It recalculates the prorated refund amount using Apex.
• It searches the legal contract PDF to quote the exact terms using a Retriever.
Imagine an agent resolving a customer's billing dispute. The prompt uses all the tools:
• It pulls the customer's current tariff plan via a Merge Field.
• It lists the last six monthly bills using a Related List.
• It calculates their average seasonal consumption using a Flow.
• It recalculates the prorated refund amount using Apex.
• It searches the legal contract PDF to quote the exact terms using a Retriever.
๐ง Facts before models. A wrong AI answer is usually just a missing fact. Always inject the right data before you try paying for a more expensive LLM.
๐งญ 360 Card — The Five Grounding Sources
๐ฏ Rule: Ground first, tune the model last. Every hallucinated or wrong answer demands a "facts audit" before anything else.
๐ Gain: You guarantee factual correctness, which builds user trust, and it is vastly cheaper than escalating to a massive model.
๐ ️ Reach for: Merge fields for a single record; Related Lists for history; Flow for declarative math; Apex for complex logic/APIs; Retrievers for documents.
๐ฐ Price: Adding more grounding data makes your prompt longer. Longer prompts consume more credits and take longer for the AI to process (latency).
๐ Limits: Field-Level Security (FLS) applies strictly and silently. If the user can't see the field, the AI can't either.
๐ฎ Later: This exact same grounding architecture is what drives your Prompt Templates, which eventually become the Custom Actions your AI agents execute.
๐ Gain: You guarantee factual correctness, which builds user trust, and it is vastly cheaper than escalating to a massive model.
๐ ️ Reach for: Merge fields for a single record; Related Lists for history; Flow for declarative math; Apex for complex logic/APIs; Retrievers for documents.
๐ฐ Price: Adding more grounding data makes your prompt longer. Longer prompts consume more credits and take longer for the AI to process (latency).
๐ Limits: Field-Level Security (FLS) applies strictly and silently. If the user can't see the field, the AI can't either.
๐ฎ Later: This exact same grounding architecture is what drives your Prompt Templates, which eventually become the Custom Actions your AI agents execute.
⚠ INTERVIEW TRAP & EXAM MISTAKE:
If an interviewer asks, "The AI gave a confident but wrong answer. How do you fix it?" Do not answer "Use a more capable model." The only correct answer is to audit the prompt trace to see what facts were actually passed to the LLM.
If an interviewer asks, "The AI gave a confident but wrong answer. How do you fix it?" Do not answer "Use a more capable model." The only correct answer is to audit the prompt trace to see what facts were actually passed to the LLM.
๐ Core Q&A & Scenarios
Q: Your Agentforce agent gives a highly confident but completely wrong answer to a customer. What is your exact first step?
๐ฏ Say this first: I will audit the facts that reached the prompt before I ever touch the model or rewrite the instructions.
Detailed breakdown:
- Confidence and correctness are totally unrelated in a Large Language Model. An LLM will lie to you with absolute certainty.
- My first step is to open the Prompt Builder trace and read the resolved prompt (what was actually sent to the LLM) rather than just looking at the final reply.
- Most wrong answers happen because the model was missing a fact and decided to fill the gap fluently by guessing.
- To fix it, I add grounding: a merge field, a Flow, or an Apex class to ensure the math or data is present.
- Changing the underlying model is my absolute last resort, because switching models mostly changes the tone, latency, and cost—it rarely fixes missing data.
Q: What happens if I ground a prompt with a field, but the user running the agent doesn't have Field-Level Security (FLS) access to it?
This is the most dangerous trap in AI development: The Silent Blank. Salesforce does not throw an error. It simply passes a blank space into the prompt where the data should be. Because the LLM doesn't know it's missing data, it will write around the gap, often hallucinating a very convincing answer based on nothing. Always check user permissions during testing!