Sub topic 3
Choosing a prompt template type
This chapter assumes you know the Salesforce data model (objects, fields, records), can find your way around Setup, and have seen Prompt Builder. You should also know what an Agentforce topic is. The previous chapter covered what a prompt template is. This one covers which template type to create, because the type decides where the template can be used and what inputs it accepts.
What a template type decides
When you create a template in Prompt Builder, you pick a type first. The type is hard to change later. It controls three things:
- Which inputs the template accepts, such as a single record or free-form values.
- Where the output can appear, such as an email composer, a record field, or a record page.
- Which agent and platform features can call the template.
The main types
| Type | Typical input | Typical output | Best fit |
|---|---|---|---|
| Sales Email | A contact or lead, plus related records | Email subject and body | Drafting outreach in the email composer |
| Field Generation | One record of an object | Text stored in a field on that record | Filling a long text field, such as a description |
| Record Summary | One record of an object | A summary of the record | Summaries shown on a record page |
| Flex | Any mix of records, text, and other values | Free text | Anything the other types do not fit |
Flex is the type that fits most agent actions. An agent often needs a template with several inputs, for example a case plus a free-text question from the user. The specialized types are built around one record and one place to show the result.
Applying it to the running example
The spine's example is a case summary for a customer call hand-off. Walk through the questions:
- The output is not an email, so Sales Email is out.
- The text is not saved in a field. The agent reads it back to a user, so Field Generation is out.
- A record summary on a Case page would fit a page component. Here the agent must also identify the case from a number the user gives, and the result is returned in a conversation.
- Flex accepts a Case input and can be extended later with more inputs.
The template body from the spine shows this. It takes a Case and uses merge fields to insert its values:
You are a service assistant. Write a short, factual summary of the case below for a customer call hand-off.
Case number: {!$Input:Case.CaseNumber}
Subject: {!$Input:Case.Subject}
Status: {!$Input:Case.Status}
Description: {!$Input:Case.Description}
Rules:
- Use at most five sentences.
- Use only the information above. If something is missing, say it is unknown.
- Do not promise refunds or dates.The $Input:Case part declares a Case record as the template's input. The next chapter covers inputs and merge fields in detail.
Common errors
- Choosing by name instead of by use. "Record Summary" sounds right for any summary. Pick it only when the output belongs on a record page. If an agent returns the text in chat, Flex gives you more room.
- Picking a type that is not offered as an action. Which types an agent can use as an action depends on your org and release. Check the action picker in Agent Builder before you design around a type.
- Starting with a narrow type and outgrowing it. If you may need a second input, such as a free-text question, start with Flex. Rebuilding a template under a new type means recreating the prompt and its resources.
- Expecting the type to enforce quality. The type does not constrain the wording of the output. Rules in the template body, like the five-sentence limit above, do that.
Exercise
A team wants an agent to answer the question "Why is this account at risk?" using an Account record and a free-text question typed by the user. Which template type fits, and why?
Show answer
Flex. The template needs two inputs, an Account record and free text. Flex accepts a mix of record and value inputs. The other types are built around a single record and a fixed place for the output, such as an email, a field, or a record page.