๐ฌ In plain words: A Prompt Template is simply a saved, version-controlled, reusable AI prompt. Salesforce offers four distinct types. And here is the golden rule: You do not manually type merge field syntax by hand. You write a placeholder word, and then use the built-in Resource Picker to replace it.
๐ Real-Life Example: Field Crew Triage
Imagine an energy company using a "Flex" template to help field crews. The template takes a Case ID as input and instantly generates a triage brief. It combines data from the Case object, the attached Asset (Meter), historical faults from a related list, and a Flow that calculates how many times a crew has visited this address before.
Imagine an energy company using a "Flex" template to help field crews. The template takes a Case ID as input and instantly generates a triage brief. It combines data from the Case object, the attached Asset (Meter), historical faults from a related list, and a Flow that calculates how many times a crew has visited this address before.
๐ฌ The Old Way vs. The Right Way (How to write templates)
❌ The Bad Way: A developer opens Prompt Builder and tries to type raw merge field syntax (like
{!$Input.Case.Status}) directly into the text box. Result? Nothing resolves correctly.
✅ The Good Way: Merge fields are inserted, not typed.
1. Write the prompt using ALL-CAPS placeholders (e.g., "The status is STATUS_HERE").
2. Put your cursor directly in front of the placeholder.
3. Click "Insert Resource" and navigate to the actual field.
4. Delete your manual placeholder word.
The Payoff: The resource picker automatically walks the object graph. From a Case, you can click through to the Account, then to the Asset, and grab a field—without writing a single SOQL query.
1. Write the prompt using ALL-CAPS placeholders (e.g., "The status is STATUS_HERE").
2. Put your cursor directly in front of the placeholder.
3. Click "Insert Resource" and navigate to the actual field.
4. Delete your manual placeholder word.
The Payoff: The resource picker automatically walks the object graph. From a Case, you can click through to the Account, then to the Asset, and grab a field—without writing a single SOQL query.
๐ง The 4 Types of Prompt Templates
Salesforce provides four specialized templates depending on what you want the AI to generate:
- Field Generation: Designed to produce a single value to fill into a specific Salesforce field (e.g., summarizing meeting notes into a "Next Steps" field).
- Record Summary: Designed to produce a highly readable, formatted summary of a single record for a human to read on a Lightning page.
- Sales Email: Designed to draft outbound emails grounded on Salesforce record data.
- Flex: The ultimate workhorse. It generates anything else you need and can take up to five different record inputs at the same time.
๐ ️ Best Practice: If two different systems (like an AI Agent and a Lightning Page) need the exact same output, put the logic in a Prompt Template. Do not hardcode instructions inside the agent.
๐งญ 360 Card — Prompt Templates
๐ฏ Rule: Use templates for reuse. If multiple surfaces need the same AI generation, abstract it into a template rather than hardcoding instructions.
๐ Gain: You gain version control, the ability to test the prompt in isolation, easy model swapping, and reusability across Agentforce, Flows, and Lightning pages.
๐ ️ Reach for: The "Flex" template whenever the other three specific types do not fit your exact use case.
๐ฐ Price: It is another piece of metadata to name, manage, version, and deploy.
๐ Limits: A Flex template is limited to exactly five inputs. Also, if you just created a new custom field, you must log out and log back in before the Resource Picker will see it.
๐ฎ Later: In Module 4, you'll learn how these templates are converted into "Actions" that your AI agent can trigger on demand.
๐ Gain: You gain version control, the ability to test the prompt in isolation, easy model swapping, and reusability across Agentforce, Flows, and Lightning pages.
๐ ️ Reach for: The "Flex" template whenever the other three specific types do not fit your exact use case.
๐ฐ Price: It is another piece of metadata to name, manage, version, and deploy.
๐ Limits: A Flex template is limited to exactly five inputs. Also, if you just created a new custom field, you must log out and log back in before the Resource Picker will see it.
๐ฎ Later: In Module 4, you'll learn how these templates are converted into "Actions" that your AI agent can trigger on demand.
⚠ INTERVIEW TRAP & EXAM MISTAKE:
If an interviewer asks how you add dynamic data to a Prompt Builder template, never say you "type out the merge field syntax." Anyone who has actually used Prompt Builder will know you are guessing. State clearly that you use the Resource Picker to insert the field graphically.
If an interviewer asks how you add dynamic data to a Prompt Builder template, never say you "type out the merge field syntax." Anyone who has actually used Prompt Builder will know you are guessing. State clearly that you use the Resource Picker to insert the field graphically.
๐ Core Q&A & Scenarios
Q: When should I use a Prompt Template instead of just putting the instructions directly inside my AI Agent?
๐ฏ Say this first: You use a template whenever more than one system needs that exact same output, or when you need strict version control and testing.
Detailed breakdown:
- Instructions hardcoded inside an Agent are locked inside that Agent. Nothing else can use them.
- A Prompt Template is a first-class piece of Salesforce metadata. You can version it, test it against real Salesforce records in isolation, and even compare how two different LLMs respond side-by-side.
- Once saved, you can trigger that template from an Agent, a backend Flow, or a button on a Lightning Record Page.
- Always remember to test your templates logged in as a restricted user! If a user lacks Field-Level Security for a grounded field, the template will not throw an error—it will simply pass a blank space to the AI, which can cause hallucinations.