Sub topic 1
Why prompts need grounding
Prerequisites
This chapter assumes you already know the following:
- The basic Salesforce data model: objects, fields, and relationships.
- Where Setup and permission sets live, and what they control.
- What a prompt to a large language model (LLM) is.
- Introductory Flow Builder concepts.
- How to read Apex syntax.
You do not need to build anything yet. This chapter explains the problem that the rest of the tutorial solves.
What an LLM knows and does not know
An LLM is trained on a large body of text collected before a fixed date. It can write fluent prose, summarize, classify, and follow instructions. It knows nothing about your org. It has not seen your cases, your accounts, or your order history.
When you ask it a question that depends on that data, it still produces an answer. The answer reads well, but the model is filling the gap with plausible text. This is often called a hallucination.
Consider this prompt:
Summarize the case for the agent taking over.The model has no case to read. It may invent a customer name, a product, or a status. Nothing in the output signals that the details are made up.
What grounding means
Grounding is the practice of placing real, current data from your org into the prompt before the model sees it. The model then works from supplied facts instead of guesses.
A grounded prompt has two parts:
- Instructions that say what to do and how to behave.
- Data that the instructions refer to, fetched from your records at the moment the prompt runs.
The same instructions can then be reused for thousands of records. Each run receives different data, and the output reflects that record.
Why ungrounded output is unreliable
Ungrounded prompts fail in predictable ways:
- Invented facts. The model supplies names, dates, and numbers that do not exist.
- Generic answers. With no specifics, the model falls back on safe, vague wording.
- Stale information. Anything the model learned in training is frozen in time. Your records change daily.
- No traceability. If the output is wrong, you cannot tell which input caused it, because there was no input.
- Inconsistency. The same question can produce different answers across runs, because nothing anchors the response.
Grounding does not make the model infallible. It narrows the model's job from "recall or invent" to "read and rewrite what is in front of you." That is a task LLMs do much more reliably.
Grounding in Prompt Builder
In Salesforce, Prompt Builder is the tool where you author prompt templates. A prompt template is a reusable prompt with placeholders. At run time, Salesforce resolves each placeholder to real data, then sends the finished text to the model.
Here is a small example of a grounded template. You will learn the syntax properly in later chapters. For now, notice that the instructions stay fixed while the values come from a record.
You are a support assistant. Summarize the case below in two sentences for an agent taking over.
Case subject: {!$Input:Case.Subject}
Status: {!$Input:Case.Status}
Priority: {!$Input:Case.Priority}
Description: {!$Input:Case.Description}
If a value above is empty, say it is not provided. Do not guess.The last line matters. Grounding supplies data, but the instructions still decide what the model does when data is missing.
Three ways to supply data
Prompt Builder offers three kinds of grounding source. This tutorial covers each in turn.
| Source | What it supplies | Typical use |
|---|---|---|
| Merge fields | Field values from the input record and its related records | Straight field lookups |
| Flow resource | Text produced by a flow | Data that needs queries or logic |
| Apex resource | Text returned by an invocable Apex method | Cases a flow cannot handle cleanly |
Start with the simplest source that meets the need. Move to Flow or Apex only when merge fields cannot reach the data.
Limits to keep in mind
Grounding moves the risk from "the model does not know" to "the data is wrong or missing." Three concerns come up repeatedly, and a later chapter covers them in detail:
- Permissions. The data a prompt can use depends on what the running user is allowed to see.
- Data quality. Empty or outdated fields produce weak output, however good the instructions are.
- Size. A prompt can only hold so much text, so you must choose what to include.
Exercise
A teammate writes the prompt "Draft a renewal email for this customer" and gives the model no record data. Name two problems you would expect, and say what grounding would change.
Show answer
Likely problems include invented details such as the customer name, contract date, or product, and a generic email that lacks specifics. Grounding would insert real values from the account and related records into the prompt at run time, so the model drafts from facts that exist in the org.