Sub topic 11
Previewing, testing and versioning a template
This chapter covers how to check a prompt template before people use it, and how to change it afterward without breaking what already works. It assumes you can already build a template of one type (Sales Email, Field Generation, Record Summary or Flex) and add merge fields to it. It also assumes you know what an activated template is, at the level of the earlier chapters. Menu labels in Prompt Builder change between Salesforce releases, so check them against your org.
Why testing a prompt differs from testing code
A prompt template does not produce the same output every time. Two previews of the same template and the same record can return different wording. You cannot test it with one exact expected value, as you can with an Apex test. Instead you check three things:
- The merge fields resolved to the values you expected.
- The response follows your instructions, such as length, tone and format.
- The response stays faithful to the data and does not invent facts.
The Preview feature supports all three checks, and versioning lets you repeat them safely after each change.
The preview panel
The Prompt Builder editor has a preview area beside the template text. You use it in this order:
- Pick a record to ground the preview. For an object-bound template (Sales Email, Field Generation, Record Summary), you search for a record of the template's object, for example a Contact or an Account. For a Flex template, you supply a value for each input you defined. An input might be a record of the chosen object type or plain text.
- Run the preview.
- Read the two outputs it gives you.
The preview shows two things, and they answer different questions:
| Output | What it shows | Question it answers |
|---|---|---|
| Resolution | The prompt after merge fields and resources are replaced with real values, before it goes to the model | Did my grounding work? |
| Response | The text the model returned for that resolved prompt | Did the model do what I asked? |
Always read the resolution first. If a field is blank or wrong there, no change to your wording will fix the response. The cause is in the data or in the merge field.
Reading a resolution
Take the Field Generation prompt from the spine:
Using the information below, write a one-sentence description of this account for a sales rep.
Account name: {!$Input:Account.Name}
Industry: {!$Input:Account.Industry}
Annual revenue: {!$Input:Account.AnnualRevenue}
If a value is empty, leave it out instead of guessing.Previewed against an account with no industry value, the resolution might read:
Using the information below, write a one-sentence description of this account for a sales rep.
Account name: Northwind Traders
Industry:
Annual revenue: 12000000
If a value is empty, leave it out instead of guessing.The blank Industry line shows the instruction about empty values will be tested. If the response invents an industry anyway, you have found a prompt weakness. You can strengthen the instruction and preview again.
What to test: a short checklist
One happy-path record is not enough. Choose several records that stress the template:
- A complete record where every field is filled in.
- A sparse record with empty fields, to test your missing-data instruction.
- A record with long text, such as a Case with a very long description, to check truncation and the length limit you asked for.
- A record with unusual characters or another language, if your users have them.
- A record the test user can see but with some fields hidden from them, since field-level security can change what resolves (see the callout below).
For a Flex template, repeat the same checks with different input values. Also test an input left empty, because a Flex template cannot rely on a record always being there.
Testing across models
The template settings include a model choice. Different models can answer the same resolved prompt with different length, tone and accuracy. When you are choosing or changing a model, keep everything else fixed. Preview the same record with each model and compare the responses side by side. If you change the prompt text and the model together, you cannot tell which change caused the difference.
The Einstein Trust Layer applies to preview calls just as it does in production. The prompt goes through its safeguards on the way to the model. Previews are real model calls, so they use your org's generative AI usage allowance. Avoid running dozens of previews in a loop without a reason.
Versions
A prompt template is a container for versions. Each version holds its own prompt text, model choice and settings. Versioning gives you a way to change a template without disturbing the one in use.
A version has a status:
| Status | Meaning | Can you edit it? |
|---|---|---|
| Draft | Work in progress, not available to users or automation | Yes |
| Active | The version that features and automation use | No, create a new version to change it |
Only one version of a template is active at a time. Activating a different version makes the earlier one inactive. Behavior of statuses can be refined in later releases, so confirm the exact labels in your org.
The version lifecycle
Why a new version instead of editing in place
Editing an active prompt directly would change production behavior for everyone at once, with no way back. Because the active version is locked, you work on a copy. Your draft can fail, be revised or be abandoned while the active version keeps serving users. When the draft passes your tests, you activate it. If a problem appears afterward, you can reactivate the earlier version, and the template's behavior returns to what it was.
Comparing two versions
A practical comparison needs the same inputs, one change and a written record. A repeatable method:
- Pick three to five test records that cover the checklist above.
- Preview the current active version against each record and save the responses somewhere, for example a spreadsheet or a note.
- Create a new version and make one change.
- Preview the new version against the same records.
- Compare the resolutions first, then the responses.
Here is a small example. Version 1 of a Sales Email template says:
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.In testing, some emails open with a long paragraph of small talk. Version 2 changes only one thing, adding a structural instruction:
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.
Open with the reason for the email in the first sentence.
Keep it under 120 words and do not invent product details.Because only one line differs, any change in the responses is easy to attribute to it. Use a version description, if your org offers one, to record what changed and why, such as "Version 2: first sentence must state the purpose". Months later, this note is the only explanation of why versions differ.
Judging model output that varies
Because output varies, run each record more than once before you decide a change helped. A single good response proves little. Look for consistency across runs. A change that makes the response right four times out of five is better than one that is right two times out of five.
Common errors and how to read them
| Symptom | Likely cause | What to check |
|---|---|---|
| A merge field appears literally, such as `{!$Input:Contact.Nmae}`, or resolves empty | Typo, wrong object or a field the user cannot read | The field name against the template's object, and the previewing user's access |
| Response ignores a constraint like word count | The instruction is vague or buried | Move it to its own sentence and state it as a number |
| Response invents facts | The data was missing and the prompt did not say how to handle it | Add an instruction such as "If a value is empty, leave it out instead of guessing" |
| Preview works but the live feature gives different output | Different record, user permissions or an older active version | Which version is active, and who is running it |
| Edit button unavailable | You opened the active version | Save a new version and edit that |
| Preview is blocked or fails | Einstein generative AI not enabled, missing permission, or the template is missing a required input | Org setup and the Flex template's input definitions |
Before you activate
A final check before you activate a version:
- Resolutions are correct for every test record.
- Responses meet your instructions on at least the complete, sparse and long-text records.
- The model choice is the one you tested with.
- The version description says what changed.
- You know which earlier version you would reactivate if something goes wrong.
Activation is covered in the next part of the tutorial, along with where an active template's output appears.
Exercise
You change a Record Summary template and the preview response now sounds worse. The resolution shows the Description field is blank for your test Case. Should you edit the wording of the prompt first? Say what you would do, and which version you would edit.
Show answer
No. A blank Description in the resolution means the problem is the grounding, not the wording. Check whether the test Case really has a description, whether the merge field name is spelled correctly (for example {!$Input:Case.Description}) and whether the previewing user can read the field. Then preview again with a Case that has a description. Do the work in a draft version, not the active one, because the active version is locked. If the wording needs a change after the grounding is fixed, save a new version, change one thing, and compare it with the earlier version using the same test records.
Exercise
Why is it a poor test to change both the prompt text and the model at the same time when comparing two versions?
Show answer
The response may differ because of the new wording, the new model, or random variation, and you cannot tell which. Change one variable at a time, keep the same test records, and run each more than once before concluding that the change helped.