Sub topic 1
What Prompt Builder is and why templates exist
Prerequisites
This chapter assumes you already know the following:
- Basic Salesforce data concepts: objects, records, fields, and relationships such as a Contact's parent Account.
- How to move around Lightning Experience and open Setup.
- What a prompt is in generative AI: text you send to a large language model (LLM) to get text back.
- Prompt Builder needs Einstein generative AI enabled in your org. You also need permission to create and manage templates, which an admin usually grants through a permission set. If you can't find Prompt Builder in Setup, check these two items first.
You don't need to write code. Some later chapters mention Apex and Flow, but this one doesn't.
What Prompt Builder is
Prompt Builder is a tool in Salesforce Setup for creating, testing, and managing prompt templates. A prompt template is a saved prompt with placeholders. When the template runs, Salesforce fills the placeholders with real data, sends the finished prompt to an LLM, and returns the response.
Three parts of that definition matter:
- The template is saved. It lives in your org as metadata, so it can be reviewed, versioned, and reused.
- The template has placeholders. These are called merge fields, and they pull values from Salesforce records at run time.
- The template is managed. Admins can preview it, compare versions, activate it, and control who can use it.
Prompt Builder does not train a model on your data, and it is not a chat window. A template is closer to a function than to a conversation. It takes inputs, runs once, and returns text.
The problem templates solve
Suppose a sales rep opens ChatGPT-style chat, pastes in contact details, and asks for a follow-up email. This works for one person, but it has several weaknesses at team scale:
- Inconsistency. Each rep writes a different prompt, so tone, length, and quality vary.
- Manual data copying. Reps paste customer data by hand. They make mistakes, skip fields, or paste data they shouldn't.
- No control. An admin can't see what was asked, can't fix a bad prompt in one place, and can't limit which model is used.
- No integration. The output stays in a chat window instead of landing in a field, an email draft, or a Flow variable.
Templates address each of these. An admin writes the prompt once and ties it to Salesforce data through merge fields. Salesforce then handles data retrieval and delivery, and the Einstein Trust Layer (covered later in this tutorial) sits between your org and the model.
What a template gives you
A template is more than a block of text. Each template carries the following:
- A name and a type. The type decides which kind of record the template is based on and where its output can appear.
- Prompt text. The instructions to the model, written in plain language.
- Merge fields and resources. Placeholders that pull in record data, related records, or other grounding sources.
- A model choice. Prompt Builder lets you pick from the models available to your org.
- Versions. Each saved change can be kept as a version. You can compare versions, and one version is active at a time.
Chapter 2 covers these parts in detail. For now, keep in mind that the type is the one decision you can't ignore. It shapes everything else about the template.
Grounding in one paragraph
Grounding means giving the model the facts it needs inside the prompt, so it doesn't have to guess. An LLM doesn't know your customer's name, open cases, or last meeting. If you ask it to "write a follow-up email" with no data, it will invent plausible details. Merge fields fix this by inserting real values before the prompt is sent.
A merge field looks like {!$Input:Contact.FirstName}. The part after $Input: names the input record and the field to read. Chapter 4 covers the syntax and the other grounding sources in depth.
How a template becomes output
The flow below shows what happens when something invokes a template. The caller could be a button on a record page, a Flow, or Apex code.
Three points follow from this flow:
- The merge fields are resolved by Salesforce, not by the model. The model only sees the finished text.
- The Trust Layer sits on both sides of the model call. It handles the outgoing prompt and the incoming response.
- The caller receives text. What happens to that text depends on the template type and on how it was invoked.
A first template
Here is a small template in the style of a Sales Email prompt. It uses the Contact record as input.
Write a short, friendly follow-up email to {!$Input:Contact.FirstName} {!$Input:Contact.LastName}, who works at {!$Input:Contact.Account.Name}.
Mention that we met recently and offer to schedule a call.
Keep it under 120 words and do not invent product details.Read it in three layers:
- Instructions: "Write a short, friendly follow-up email", "offer to schedule a call".
- Grounding: the three merge fields.
Contact.Account.Namefollows a relationship from the Contact to its Account. - Guardrails: "under 120 words" and "do not invent product details". These limit length and reduce made-up content.
When a rep runs this for a Contact named Priya Nair at Northwind Traders, the model receives a prompt like this:
Write a short, friendly follow-up email to Priya Nair, who works at Northwind Traders.
Mention that we met recently and offer to schedule a call.
Keep it under 120 words and do not invent product details.The rep never sees the placeholders. The admin maintains one template, and every rep gets a consistent prompt.
The "do not invent product details" line is a guardrail, not a guarantee. A model can still produce text that is wrong, so a person should review output before it is sent to a customer.
Where the template types fit
The type is chosen when you create a template. It controls what the template is based on and where the output is used. The table below is only a preview. Chapters 3 and 5 through 9 cover each type fully.
| Type | Based on | Typical output |
|---|---|---|
| Sales Email | A record such as a Contact or Lead | An email draft for a rep to review |
| Field Generation | A record of a chosen object | Text written into a field |
| Record Summary | A record of a chosen object | A summary shown to the user |
| Flex | Inputs you define yourself | Text returned to whatever invoked it |
Flex stands apart from the other three. The first three are bound to a Salesforce object. Flex lets you define your own inputs, which can be a record, but can also be other values. Because of that, a Flex template can be used in places the object-bound types can't.
Why not just use one prompt for everything?
A fair question is why Salesforce offers several types instead of one general template. The reason is that the types connect to the product in different ways:
- A Sales Email template plugs into email composition, so the output appears where a rep writes an email.
- A Field Generation template plugs into a record page, so the output appears in a field.
- A Record Summary template is meant to show a summary of a record.
- A Flex template is the general option, so you decide how to feed it and use its result.
Picking a type is therefore a decision about integration, not only about wording. The same prompt text could be valid in more than one type. The deciding factor is where you want the result to go. Chapter 9 gives you a decision method.
Common mistakes at this stage
- Treating a template as a chat. A template runs once with the inputs you give it. It does not remember earlier runs.
- Skipping grounding. A prompt with no merge fields invites invented facts. If the answer depends on record data, bring that data in.
- Assuming empty fields are harmless. If a merge field has no value, the prompt may contain a blank. Add an instruction such as "if a value is empty, leave it out instead of guessing".
- Putting sensitive data in without thinking. Merge fields send record values to the model. The Trust Layer helps protect them, but you should still choose fields on purpose.
- Editing the active version in a hurry. Changes should go into a new version that you preview first. Chapter 11 covers this workflow.
- Forgetting the license and setup requirements. If the Prompt Builder page is missing, the cause is often disabled generative AI or missing permissions, not a problem with your template.
What you can do after this chapter
You should now be able to:
- Say what Prompt Builder is and what a prompt template consists of.
- Explain why a managed template beats a prompt typed into a chat window.
- Read a simple template and tell its instructions from its grounding and guardrails.
- Name the four template types and say which one isn't tied to a single object.
The next chapter looks at the parts of a template in more detail.
Exercise
A rep pastes customer data into a chat tool every time they want a follow-up email. Give three reasons a prompt template in Prompt Builder is a better approach, and say what the merge field {!$Input:Contact.FirstName} does.
Show answer
Any three of these: the prompt is written once and gives consistent tone and quality; data comes from the record through merge fields, so reps don't copy and paste it; an admin can preview, version, and change the prompt in one place; the output is delivered into Salesforce, for example as an email draft, instead of staying in a chat window; the Einstein Trust Layer sits between the org and the model. The merge field {!$Input:Contact.FirstName} is a placeholder that Salesforce replaces with the first name of the input Contact record before the prompt is sent, so the model receives the real value.
Exercise
Look at this prompt: "Write a summary of this customer's history." It has no merge fields. What is likely to go wrong, and how would you fix it?
Show answer
The model has no access to the customer's data, so it will either ask for details or invent a history. Fix it by grounding the prompt: add merge fields for the relevant record fields, such as the account name and case subject, and add a guardrail like "if a value is empty, leave it out instead of guessing".