Use conditional blocks to create dynamic prompt templates that adapt based on your grounded data.
Required Editions
| Available in: Lightning Experience |
| Available in: Enterprise, Performance, and Unlimited Editions with the Einstein for Platform, or Einstein or Agentforce for Sales or Service add-on, or Agentforce Foundations |
| User Permissions Needed | |
|---|---|
| To create and manage prompt templates in Prompt Builder: |
Prompt Template Manager permission set
OR Customize Application permission set |
Identify the merge fields you want to use in your conditions. These fields come from your grounded data sources, such as objects, flows, or custom resources.
Add a Conditional Block
- From Prompt Builder, open or create a prompt template.
- Position your cursor where you want to add conditional logic.
- Type / to open the slash-command menu.
- Select Conditional Block or If Statement.
- In the condition field, enter your expression using merge fields and operators. For example, {!Case.Priority} == "High".
-
Add text for the
ifbranch. This text appears when the condition is true. - Optionally, click Add Else If to add conditions for other scenarios.
- Optionally, click Add Else to add text when no conditions are true.
- Test your conditional logic with Preview and sample data.
- Click Save.
Review tips for writing conditions.
- Use the @ symbol to insert merge fields from your grounded data.
- Wrap text values in quotes. For example, {!Account.Type} == "Enterprise".
- Combine multiple conditions. For example, {!Case.Priority} == "High" and {!Case.Age} > 7.
- Use parentheses for complex logic. For example, ({!Amount} > 100000) or ({!Stage} == "Closed Won").
- Test with various data scenarios to make sure that your conditions work as expected.
Review common conditional patterns.
- Check if a field has a value: If a contact has an email, display it.
- Compare numbers: Identify high-value opportunities.
- Check multiple conditions: Prioritize cases based on status and priority.