Use Conditional Logic in Prompt Templates (Beta)
Create dynamic, context-aware prompts using conditional logic in the Block Editor. Add if, else if, and else statements to tailor AI responses based on input variables and 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 |
With conditional logic, your prompt templates adapt dynamically based on context. Instead of creating multiple similar templates for different scenarios, you can build a single intelligent template that adjusts its behavior based on conditions you define.
Review what you can do with conditional blocks.
- Adjust tone and messaging - Tailor communication style based on customer tier, case priority, or relationship status.
- Include or exclude content - Show detailed technical information only when relevant, or customize sections based on data values.
- Personalize responses - Customize AI output based on product type, service level, or user preferences.
- Handle multiple scenarios - Address different business cases within a single template.
Understand How Conditional Logic Works
Conditional blocks evaluate expressions using merge fields from your grounded data sources. When a condition is true, the corresponding content is included in the prompt sent to the AI model.
The Block Editor uses conditional expressions. Review these supported operators.
- Comparison:
==(equals),!=(not equals),>(greater than),<(less than),>=(greater than or equal),<=(less than or equal) - Logical:
and,or,not - Membership:
in(check if value exists in a list)
You can place conditional blocks inside other conditional blocks to create more complex logic. For example, you can first check if a case priority is High, and then within that condition, check if the customer tier is Premium to determine the appropriate response strategy.
Review these example use cases.
- Customer Service: "If case priority is High, use urgent tone and escalate to the senior support team."
- Sales: "If opportunity value > $100,000, include executive summary and ROI calculator."
- Marketing: "If the customer tier is Premium, mention exclusive benefits and dedicated support."
- Nested Example: "If case priority is High and customer tier is Premium, assign to a dedicated account team; otherwise if case priority is High, assign to standard escalation team."

