4.4 Creating, Activating & Executing Prompt Templates
Key Takeaways
- Saving a new prompt template creates Version 1, and Save As > Save as a New Version creates additional versions for comparison.
- Only one version of a prompt template can be active, and a template with no active version is unavailable to users.
- Activating a version makes it immutable, even if it's later deactivated; edit by saving a new version.
- Preview settings let builders select records and display the resolved prompt and generated response before activation.
- At run time, a template's merge fields are resolved with the executing user's access, protected by the Trust Layer, sent through the LLM gateway, and logged for audit.
4.4 Creating, Activating & Executing Prompt Templates
Quick Answer: Create a template in Prompt Builder by choosing a type, writing instructions, and inserting grounding resources. Preview the resolved prompt and response against real records. Save versions as you iterate, then activate one version to make it available. Activation makes that version immutable, and only one version can be active. At run time, the activated template is resolved with the executing user's data access, protected by the Einstein Trust Layer, sent through the LLM gateway, logged, and returned to the caller.
Step 1: Create
- From Setup, open Prompt Builder and click New Prompt Template.
- Choose the Prompt Template Type (Field Generation, Flex, Sales Email, and so on).
- Enter the name and the type-specific settings: object and field for Field Generation, or resources for Flex.
- In the Prompt Template Workspace, write the prompt and use Insert Resource (or type @) to add merge fields:
- Record fields and related lists
- Flows (template-triggered prompt flows) and Apex
- Retrievers (individual, ensemble, or web)
- Data 360 DMOs, and other resources available for the type
- Prompt template actions (other active templates)
- Configure Template Settings:
- Model: select the LLM configuration for this version
- Response format: JSON or HTML structured output where needed
- Retriever settings: search text, output fields, and number of results
- Optionally use AI Assist or the example library for starting text.
Step 2: Preview and Revise
Prompt Builder's preview simulates the full run-time experience:
- In Preview Settings, pick input records (and resource values for Flex).
- Choose Generate Response, Display Prompt, and Display Resolution as needed.
- Review the Resolved Prompt, where every merge field is replaced with real data. Resolution is enabled by default.
- Review the Response. Each run is a new LLM call, so the same resolved prompt can produce different responses.
- Check Data Masking Details where masking applies, and Performance Insights for token usage and generation metrics.
- If a prompt is too large for the model, a summary can be generated in the Resolution panel. You can use it or build a smaller prompt.
Iterate by editing instructions, grounding, or model, and re-preview. Evaluate responses for factual accuracy, harmful content, and bias.
Step 3: Version and Activate
| Action | Result |
|---|---|
| Save (first time) | Creates Version 1. The version number becomes part of the URL |
| Save (later) | Saves changes to the current version, if it has never been active |
| Save As → Save as a New Version | Creates Version 2, 3, and so on with any unsaved changes |
| Save As → Save as a New Template | Creates a separate template (not supported for Flex) |
| Activate | Makes this version available to users and callers. Status changes from Draft to Published |
| Deactivate | Removes the version from use. If no version is active, the template is unavailable |
Rules that appear on the exam:
- Only one version can be active at a time. Activating another version switches which one users get.
- Templates aren't available to users by default. You must activate a version.
- Activating a version makes it immutable. Even after deactivation, any version that was ever active stays immutable. To change it, save a new version.
- A new version doesn't automatically become available to users; activate it.
- If a template is in use, you can't deactivate its active version unless another version is active, and you can't delete the active version.
- Each version can use a different model configuration, but only the activated version's model is used.
- Prompt Template References show the flows, agents, and other components that depend on a template, so check them before changing activation.
Step 4: Execute
Invocation options
| Caller | How it runs the template |
|---|---|
| User on a record page | Clicks the generative field icon (Field Generation) |
| Rep in email composer | Selects a Sales Email template |
| Flow | Prompt template action in Flow Builder |
| Apex / Connect REST API / Connect in Apex | Invocable action or API call |
| Agent | A custom agent action that references the template, or standard actions such as Summarize Record |
| Another template | A prompt template action. Only active templates qualify, with up to five in a prompt chain |
| Batch | Prompt template batch processing across many records |
| Testing Center | Batch-test a template version across many inputs with scorers |
What happens at run time
- The template is invoked with input from an agent, flow, Apex, or app.
- Prompt resolution with secure data retrieval: merge fields are filled using the executing user's permissions. Dynamic grounding can pull structured and unstructured Data 360 content through retrievers, flows, and queries.
- Trust Layer protections apply: pattern-based and field-based data masking where enabled (disabled when called through agents), plus prompt defense system policies.
- The secured prompt goes through the LLM gateway to the model. External providers operate under zero data retention. The response can include citations.
- The response is logged for audit and feedback.
- Response protections apply: toxicity detection, and demasking replaces placeholders with the original values.
- The response returns to the caller in raw or structured format.
Scenario: Safe Iteration
A team's active Version 3 of a case summary template sometimes omits the resolution. They:
- Open Version 3 (immutable), then use Save as a New Version to create Version 4.
- Add an instruction such as "Always include a Resolution line; if none exists, write 'Resolution: Not yet determined'."
- Preview against several closed and open cases, and batch-test in Testing Center with a Completeness scorer.
- Check Prompt Template References to see which flows and agents use the template.
- Activate Version 4. Version 3 is deactivated automatically, so users and agents immediately get Version 4.
Exam Traps
- "Edit the active version" is never the answer. Save a new version.
- Deactivating the only active version of an in-use template is blocked.
- Preview uses real records and a real LLM call, so review responses each time.
- Prompt template actions require active templates. A draft can't be chained.
A builder needs to change the instructions in Version 2 of a prompt template, which was active last month but is now deactivated. What must the builder do?
An admin saves Version 3 of a template with improved instructions, but users still receive Version 2 behavior. Why?
During preview, which Prompt Builder output shows the template's merge fields replaced with actual record data?
A developer wants one prompt template to call another template and use its output. Which requirement applies?