Sub topic 8
Flex Templates and Flexible Inputs
This chapter assumes you know Salesforce objects, records and fields, can find Prompt Builder in Setup, and have a general idea of what a prompt is. It also assumes Einstein generative AI is enabled in your org.
What makes Flex different
Sales Email, Field Generation and Record Summary templates are each bound to one purpose. Each one expects a specific object as its input, and its output goes to a fixed place, such as an email body or a field.
A Flex template has no fixed purpose. You choose the inputs yourself. You can add one record input or several, and each can be a different object. The output is text that the caller decides how to use.
| Aspect | Object-bound types | Flex |
|---|---|---|
| Inputs | One record of a set object | Inputs you define, of mixed types |
| Output location | Fixed by the type | Chosen by whatever invokes the template |
| Typical use | Email draft, field value, summary | Scenarios the other types do not cover |
Defining inputs
When you create a Flex template, you add inputs in the template's configuration. Each input has a name and a type. Common input types are a Salesforce record of a chosen object, and free text.
The input name sets the merge field syntax. If you name a Case input Case, you reference its fields as {!$Input:Case.Subject}. If you name it SupportCase, the reference becomes {!$Input:SupportCase.Subject}. A mismatch between the name and the merge field is a common cause of empty values in a preview.
Summarize this case for a support manager in three bullet points: the problem, what has been tried, and the next step.
Subject: {!$Input:Case.Subject}
Description: {!$Input:Case.Description}This prompt works in a Record Summary template. It also works in a Flex template whose input is a Case record named Case.
Using several inputs
The main benefit of Flex is combining sources. Suppose you want a briefing that uses an Account and a free-text note from the user. You define two inputs, an Account record named Account and a text input named Focus. The prompt can then refer to both.
Write a short meeting briefing for a sales rep about {!$Input:Account.Name}.
Industry: {!$Input:Account.Industry}
The rep wants to focus on: {!$Input:Focus}
If a value is empty, leave it out instead of guessing.The record input is grounded in real field values. The text input carries whatever the caller supplies at run time.
How a Flex template gets its inputs
Because a Flex template is not tied to a page, nothing fills its inputs automatically. The caller must supply them. This shapes how you plan its use:
- Preview. In Prompt Builder you pick a record for each record input and type text for each text input.
- Invocation. A flow, an Apex class, or another automation passes the values in when it calls the template.
The next chapters cover choosing a type and activating templates. For now, remember that a Flex template needs a caller that knows what to pass.
Common errors
- Wrong input name in the merge field. The name after
$Input:must match the input you defined, including case. - Missing related data. A merge field such as
{!$Input:Contact.Account.Name}only returns a value if the relationship is populated on the record you select. - Expecting automatic placement. A Flex template does not write to a field or open an email on its own. The invoking process handles the output.
- Using Flex when a specific type fits. If your scenario is a plain email draft or a single field, the dedicated type gives you the built-in place for the output.
Exercise
A Flex template has a record input named Opportunity. A teammate's preview shows blank values where the prompt uses {!$Input:Deal.Name}. What is wrong, and how do you fix it?
Show answer
The merge field refers to an input named Deal, but the input is named Opportunity. The input name sets the merge field syntax, so change the reference to {!$Input:Opportunity.Name} (or rename the input to match).
Exercise
Name one reason to choose a Flex template over a Record Summary template.
Show answer
Flex lets you combine several inputs, such as an Account record plus free text from the user, and lets the caller decide where the output goes. Record Summary takes one record of its object and fixes where the summary appears.