Grounding Prompt Templates, Versions, Activation
Agentforce Specialist · Lesson 2 of 14 · 10:28
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Salesforce Agentforce Specialist exam. In this lesson: grounding a prompt template with merge fields, related lists, flows, Apex, and Data 360 retrievers, choosing the right technique, saving versions and activating one, where an active template runs, and the practices that make prompts give steady results. Includes three original practice questions, with Sunmeadow Solar, a fictional solar installer, as the example.
Study notes
The text of this lesson, to read at your own pace. Information as of December 2026.
A draft that works only once
Sunmeadow's admin has a first draft of the site survey email, and it reads well. But the draft names one customer, one town, and one installer, so it works exactly once. This lesson shows how to ground the template in live data, how to take it from draft to active, and how to write prompts that give steady results.
Grounding techniques
Grounding means adding your company's data to the prompt, so the model answers about this customer, and not in general terms. In the Prompt Template Workspace, you add that data from the resources list, as placeholders that are filled at run time. A hard coded prompt serves one case, while a grounded template serves every record.
Merge fields and related lists
The simplest resource is a merge field, which inserts the value of a field from the record, such as the customer's name or the panel model. For a sales email, you can also merge fields from the sender and the recipient. And a related list adds a set of related records, such as the recent cases on an account.
Flow and Apex
When the data needs logic, a flow can feed the template. A template triggered prompt flow picks the right records with conditions, such as only the open cases, and returns text to the prompt, without code. When you need a SOQL query, a call to an external system, or careful filtering and formatting in code, use Apex. The Apex class exposes an invocable method, labeled with the capability type of the template, and its result becomes a resource in the prompt.
Retrievers
Long, unstructured content is different, such as knowledge articles or the PDF manuals of inverters. A retriever from Data 360 searches that content by meaning, and adds only the most relevant passages to the prompt. This is retrieval augmented generation, and lessons four and five cover it in depth.
From draft to active
To build a template, you pick its type, give it a name and an API name, and set its object or inputs. You write the prompt in the workspace, add resources, and choose the model, or keep the default one. Then you preview it on a real record, and see both the resolved prompt and the response. When you save it for the first time, it becomes version one of the template.
Versions and activation
To try other wording, data, or models, you save the work as a new version, and compare the results. Users can run a template only after you activate a version, and only one version is active at a time. A version that was ever active becomes immutable, even after you deactivate it, so to change it, you save a new version. And a new version is not active by default, so you must activate it to make it live.
Where templates run
Once active, a template runs wherever its type allows. Field generation runs from a button on the record page, and sales email from the email composer. Flows and Apex can call a template, and so can an agent, through a prompt template action. Developers can also call it through the REST API, or run it on many records in a batch.
Writing effective prompts
Good prompts are concise and clear, in natural language, without jargon. Give the model a role and a goal, for example, you are a solar advisor who invites a homeowner to book an installation. Keep one writing style across your templates, because the model mirrors your words, your tone, and even your punctuation. And iterate: try several versions, and ask the people who use the output what works.
Instructions and output
Keep the context apart from the instructions: on its own line, write instructions, followed by the instructions inside triple quotes. Ask the model to generate only the content you need, such as only the message to send, so it does not describe its own process. Start from the example templates that Salesforce provides, and study their wording. And remember that grounding beats long explanations, because real data makes the answer specific.
Recap
Let's recap. Grounding fills the template with live data, so one template serves every record. Use merge fields for values, related lists for related records, flows for logic without code, Apex for queries, callouts, and code, and retrievers for unstructured content. You build in the workspace, preview on a real record, and save versions. Only one version is active, and an activated version is immutable, so you change it by saving a new one. Write concise prompts with a role, a clear instructions section, and a request for only the output you need.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
A support template must include the passages from PDF inverter manuals that match the customer’s problem. Which grounding technique fits?
- A merge field
- A related list
- A retriever
- A fixed sentence in the prompt
Show the answer
A retriever
A retriever searches the manuals by meaning, and adds only the matching passages to the prompt. “A merge field” is wrong, because a merge field adds one field value, and cannot search the content of documents. “A related list” is wrong, since a related list adds related records, not passages from a manual. And “A fixed sentence in the prompt” is wrong, because a fixed sentence in the prompt would give every customer the same text.
Version 2 of the email template is active, and the admin must change its wording. What should the admin do?
- Deactivate version 2, then edit it
- Delete the template and start again
- Activate a copy next to version 2
- Save as a new version, then activate it
Show the answer
Save as a new version, then activate it
An active version is immutable, so the admin saves the changes as a new version, then activates it. “Deactivate version 2, then edit it” is wrong, because a version that was ever active cannot be edited, even after it is deactivated. “Delete the template and start again” is wrong, since deleting the template would also remove it from every place that uses it. And “Activate a copy next to version 2” is wrong, because two versions cannot be active at the same time.
Some generated emails start with a line like “Here is a draft I wrote for you”. Which change fixes this BEST?
- Switch the template to a different model
- Instruct it to generate only the message
- Add more merge fields to the prompt
- Give the template a shorter name
Show the answer
Instruct it to generate only the message
An instruction to generate only the message for the customer stops the model from describing its work. “Switch the template to a different model” is wrong, because a different model may still add the same kind of line. “Add more merge fields to the prompt” is wrong, since more merge fields add data, but do not change what the model writes around it. And “Give the template a shorter name” is wrong, because a shorter template name has no effect on the response.