Prompt Builder and prompt templates
Prompt template types, grounding templates with merge fields, flows, Apex, data graphs and retrievers, choosing models, using templates in Lightning, Flow, Apex and agents, versioning and testing prompts.
Simple explanation
Prompt templates are reusable, grounded prompts.
| Template type | Typical use |
|---|---|
| Sales email | Drafting emails from record context |
| Field generation | Filling a field (for example a case summary) |
| Record summary | Summaries in Lightning |
| Flex | Any inputs, any use (most flexible) |
Grounding inside templates: merge fields, related lists, Flow or Apex for computed context, data graphs, retrievers for RAG.
Where templates run: Lightning (field generation, summaries), Flow and Apex (Models API calls through the template), and as agent actions.
Good practice
- Clear role, task, constraints and output format.
- Minimal, relevant grounding.
- Version and test with representative records before activation.
- Choose a model suited to the task (cost, quality, latency).
- All calls go through the Trust Layer.
Real-world analogy
A prompt template is a mail-merge letter with a brain: the letter structure is fixed, the details come from the record, and the writer adapts the wording to fit.
Worked example
A field generation template creates a case wrap-up summary from the case, its emails and the chat transcript, in five bullet points with next steps. An agent action uses the same template to summarise before handing over to a human.
Diagram
Key points
- Types: sales email, field generation, record summary, flex.
- Ground with merge fields, Flow, Apex, data graphs, retrievers.
- Reuse templates across Lightning, Flow, Apex and agents.
- Version, test and choose models deliberately.
- Calls pass through the Trust Layer.
Limits and gotchas
- Prompt calls consume credits; avoid generating on every record save when not needed.
- Grounding that pulls too many related records bloats prompts.
- Output format drift: ask for structured output and validate it.
π€ How to say this in an interview
Explain template types, a grounding choice, and how you test and version prompts.
Common follow-ups
When use a prompt template action rather than letting the agent write freely?
When output must follow a fixed structure, use specific grounding, or be reused outside the agent.
How do you test a prompt template?
Run it against a set of representative records, review outputs against criteria, and compare versions before activation.