Agentforce
Prompt Builder conditional logic: testing every branch before activating a template
Prompt Builder's conditional blocks let grounded data choose which instructions reach the model. That makes one template more flexible and gives you more paths to test. Learn how the beta works, where its collection limit matters, and how to combine branch checks, dependency review, and prompt testing before activation.
Your premium customer and your standard customer can need different instructions in the same email template.
You could keep two nearly identical templates and fix both whenever the policy changes. Or you can let a verified field choose which instructions the model receives. That second option reduces duplicated text, but it creates branches your release review has to inspect.
Salesforce’s conditional logic documentation describes beta blocks for if, else if, and else in Prompt Builder. Use them to select content from grounded data. Keep permissions and consequential business decisions in the code or Flow that owns the operation, and test every relevant branch before activating the template.
Conditional blocks select the prompt before generation
The conditional expression evaluates a grounded merge field. When the condition is true, the associated content becomes part of the prompt sent to the model. Salesforce documents comparison, logical, and membership operators, along with nested conditional blocks.
That gives you a useful separation. The platform chooses the relevant instruction from the supplied data. The model generates language under that instruction. A customer-tier field can select a service-level explanation without asking the model to infer the customer’s tier from a conversation.
The branch still depends on the field being correct. If a premium account has the wrong tier value, your template can resolve exactly as configured and produce the wrong explanation. Inspect the grounding source before treating conditional logic as a fix for inconsistent output.
Conditions also don’t make the generated response deterministic. Selecting the same instruction twice can still produce different wording or omit a requested detail. Your evaluation must examine the resolved prompt and the generated output as separate artifacts.
Our Prompt Builder overview covers template types and grounding. The additional design decision here is which differences belong inside one template. Use a branch when the output has the same purpose and needs a small contextual variation. Separate fundamentally different jobs before one template becomes a maze.
The beta is documented before Dreamforce
This capability wasn’t first released in the September keynote. The Summer ‘26 release note dates availability from the week of June 8, 2026, and labels it beta. Salesforce’s September 28 Dreamforce roundup again lists Conditional Expressions as beta.
That roundup also distinguishes two adjacent capabilities: prompt-template reference visibility is generally available, while Prompt Testing is beta. Those statuses matter more than treating the whole announcement as one newly available feature. Verify each capability your release plan needs.
The current conditional logic help page places the setting under Einstein Setup, in the Prompt Builder section, as Conditional Logic for Prompt Templates (Beta). The release note describes it under Prompt Builder Settings. Follow the current help and the labels in your org rather than relying on the sequence of clicks in an older screenshot.
The documentation ties conditionals to the Block Editor. Review the supported edition and add-on combinations in the current help before promising access. A template design is portable as an idea; access to a beta feature still depends on what your org supports.
For a first evaluation, choose a sandbox and a template with a narrow purpose. Keep the existing production template available while you inspect the new version’s resolution and outputs. A beta setting shouldn’t become an incidental dependency hidden inside a routine copy edit.
A prompt branch cannot authorize a business action
Suppose a service template chooses between a premium and a standard escalation explanation. The branch can select the relevant wording. It cannot establish that a refund is permitted, that the user can see a record, or that an account qualifies for a contractual exception.
Those decisions need an authoritative result. If your Flow action or custom Apex action determines eligibility, pass that result into the prompt and let the template explain it. The action must still enforce its rule if the prompt is missing, edited, or bypassed.
Keep record access in the grounding path. A conditional block that says to exclude private details doesn’t repair a query that already returned data the user couldn’t access. Review Agentforce permissions and the running identity of the actual caller.
Avoid combining business-policy changes with template simplification. If your old premium template promises a particular response time, merging it into a conditional template should preserve the approved promise. Any change to that promise deserves the policy owner’s review, even if the implementation looks like a small text edit.
Write the source of each policy-bearing value beside the template design. The reviewer should know which field selects the branch, who maintains it, and what happens if it is absent. A branch is easier to trust when its inputs have owners.
Related collections need preparation outside the block
Salesforce documents a specific limitation: conditional blocks evaluate a single related record and don’t iterate over a collection, such as multiple files related to a case. Don’t design a template around a loop the feature doesn’t provide.
If your decision depends on several invoices, quote lines, or documents, calculate the relevant result before prompt resolution. A Flow or Apex step might determine whether any invoice is overdue, assemble approved lines, or select a current policy document. The appropriate implementation depends on the data and the task.
Pass a small result with a defined meaning. For example, a verified overdue balance can select the collections explanation, while a reviewed list supplies the supporting invoices. The template should not have to infer the aggregate from a long, unstructured dump of records.
Keep missing data distinct from a negative result. “No overdue invoices” and “invoice data unavailable” justify different responses. If both resolve to the same branch, the model can reassure a customer on the basis of a failed retrieval.
That preparation can also reduce unnecessary context. Return the fields needed to explain the result rather than every related record. Our prompt token budget guide explains why more grounding text doesn’t automatically produce a better answer.
Build a branch test set before editing the wording
Start with inputs that select each intended branch. Include a normal premium account, a normal standard account, a missing tier, and a value outside the expected set. If your condition contains a threshold, include records just below, at, and above that boundary.
For nested conditions, identify the combinations that matter to the business rule. A premium account with a high-priority case may need a different explanation from a premium account with an ordinary case. Write the expected instruction for each selected test before evaluating the generated response.
Inspect the resolved prompt first. Confirm that it includes the chosen content and excludes irrelevant branches. Then check the response for factual grounding, required details, permitted promises, and its handling of missing information. A correct branch can still produce an incomplete answer.
Salesforce’s Dreamforce roundup describes batch prompt testing over many inputs and marks Prompt Testing beta. Where available, use that capability to repeat your cases. The announcement doesn’t specify a universal supported batch size or prove that every org already has the same controls.
Keep your evaluation data and expected results versioned even if you begin with manual testing. They should cover each revision of the template and its grounding logic. For an agent that uses the template, add the relevant conversations to its agent regression suite as well.
Before activation, review the template’s callers. Salesforce’s announcement describes reference visibility for flows and actions that depend on it. Check those consumers, then test their expected inputs. A branch that works in the authoring preview can fail when an existing caller supplies a missing field.
Understanding the basics
What is conditional logic in Salesforce Prompt Builder?
It is a beta Block Editor capability for adding if, else if, and else conditions to prompt templates. Conditions evaluate grounded merge fields and determine which content is included in the prompt. The model then generates its response from the resolved prompt.
Is Prompt Builder conditional logic generally available?
The current help page and Salesforce’s September 28 Dreamforce roundup label it beta. The Summer ‘26 release note dates its availability from the week of June 8, 2026. Check your org’s current access and supported licensing before relying on it.
Can conditional blocks loop through related records?
Salesforce says conditional blocks evaluate a single related record and don’t iterate over a collection. Prepare collection-based decisions in a suitable grounding step, such as Flow or Apex. Pass the computed result and the required supporting data into the template.
Does batch prompt testing replace an agent’s conversation tests?
No. A prompt test checks template resolution and generated content, while a conversation test checks how the agent chooses and uses that template. An agent can select the wrong action even when the template itself performs well.
Activate the template with its callers in view
Before the release, ask a reviewer to trace one expected input from the calling Flow or action through the selected branch to the final answer. Repeat that review for missing data and the policy-sensitive case. The reviewer should be able to identify the source of every consequential statement.
Keep the previous approved version and the evaluation set ready for a rollback. Conditional blocks can remove duplicated templates, but the useful gain is a smaller set of instructions you can maintain and test. Stop adding branches when they make that job harder.
Combining prompt templates or preparing an Agentforce release? Talk to us. Our Agentforce implementation work covers grounding and evaluation, and the org health scorecard can help you identify the data and access issues to resolve first.