Lesson 20 of 41 · All lessons
Salesforce Agentforce Specialist
0 of 41 complete
1Exam Overview
  1. 1.1Agentforce Specialist Complete Exam Overview
2Prompt Engineering20%
  1. 2.1When to Use Prompt Builder
  2. 2.2Prompt Template Access Controls
  3. 2.3Field Generation and Flex Prompt Template Types
  4. 2.4Grounding Techniques for Prompt Templates
  5. 2.5Creating, Activating, and Executing Prompt Templates
  6. 2.6Best Practices for Writing Effective Prompts
  7. 2.7Trust Layer Security and Privacy Features
  8. 2.8Managing and Preventing Specific Models from Being Accessed
3Data 360 Fundamentals20%
  1. 3.1Agentforce Data Library
  2. 3.2Data 360 Concepts for Agentforce
  3. 3.3Chunking
  4. 3.4Indexing
  5. 3.5Retrievers
  6. 3.6Choosing a Grounding Approach for a Scenario
4AI Agents35%
  1. 4.1How an Agentforce Agent Works
  2. 4.2Agent Building Blocks and Agent Script
  3. 4.3Hybrid Reasoning and Deterministic Behavior
  4. 4.4Agentforce Builder: Canvas and Script Views
  5. 4.5Filters, Variables, and Template Expressions
  6. 4.6Standard and Custom Topics
  7. 4.7Standard and Custom Agent Actions
  8. 4.8Configure Topics, Instructions, and Actions for a Use Case
  9. 4.9Connecting Agents to Digital Experience, Email, Voice, and Slack
  10. 4.10Agent Security Context and Action Execution
  11. 4.11Choosing Between Employee and Service Agents
  12. 4.12When to Use Agent API
5Testing, Deployment, and Maintenance10%
  1. 5.1Testing Agents with Testing Center
  2. 5.2Understanding Testing Center Evaluations
  3. 5.3Deploying Agents from Sandbox to Production
  4. 5.4Deploying Prompt Templates Between Environments
  5. 5.5Reviewing Agent Behavior After Changes
6Governance and Observability10%
  1. 6.1Managing and Monitoring Agents
  2. 6.2Agent Analytics and Performance Signals
  3. 6.3Identifying Opportunities to Optimize Agent Behavior
  4. 6.4Using Observations to Guide Improvements
7Multi-Agent Orchestration5%
  1. 7.1Choosing a Multi-Agent Architecture
  2. 7.2Orchestrators and Connected Subagents
  3. 7.3Handoff and Supervisor Modes
  4. 7.4Model Context Protocol (MCP)
  5. 7.5Agent-to-Agent (A2A) Communication

Section 4 · AI Agents · 35% of exam

4.5 Filters, Variables, and Template Expressions

3 min read Updated Nov 16, 2026

Exam objective

Explain how variables, filters, and expressions can make agent behavior more controlled, context-aware, and consistent.

Variables store usable context

Variables store values an agent can reuse in reasoning and interactions. A value might represent whether a customer has been verified, which product they selected, or an output returned by an action. Variables can be referenced in instructions, expressions, action inputs, and filter conditions. This is safer and more consistent than asking a language model to reconstruct a value from a long conversation every time. In current Agentforce Builder, variables can be created in the Variables page, and an action output can be mapped to a variable. Some context values are read-only or have restrictions on when they can be set, so check the current variable definition and API behavior before designing around it.

Filters limit availability

A filter makes a topic or subagent or action available only when specified conditions are met. A condition typically compares a variable with a value using an operator. Multiple conditions can be configured to require all conditions or any condition, depending on the intended logic. For example, a verified-customer variable can control access to a refund action. A filter affects whether the agent can use that asset; it is not merely a suggestion to the model. Apply filters to the correct subagent or action, and make sure the variables have trustworthy values before the decision is made.

Expressions and resource references

Agent Script uses expressions to compare values, set variables, and control transitions. Salesforce documents a variable reference format for instructions, {!@variables.VariableName}, and for logical expressions, @variables.VariableName. These references allow instructions and conditions to use the current value rather than hard-coded text. The variable must exist and be set at the right time. Check spelling, value type, null behavior, and whether the expression is evaluated before or after an action. Template expressions can make instructions context-aware, but they do not validate that the source value is accurate or authorized.

Design a controlled path

Suppose an agent can submit a replacement order only after checking eligibility. A lookup action returns order status and purchase date. Map reliable action outputs to variables, calculate or evaluate eligibility with deterministic logic, and add a filter so the replacement action is available only when the eligibility condition is true. If details are missing, ask for them or run a permitted lookup. If the user is not authenticated, route to verification rather than exposing an action. Test each state: verified and eligible, verified but ineligible, unverified, missing order, and action failure. This verifies the whole dependency chain rather than only the filter formula.

TIP: When a filter does not behave as expected, check the variable’s source and timing first, then inspect the condition, operator, value type, and asset where the filter is applied.

Filters restrict agent access to configured assets; Salesforce sharing, object permissions, field-level security, and action-level authorization remain separate controls.

Extra concept: A variable mapped directly from an action output is usually more dependable for a gating decision than a value inferred from ambiguous prose.

Official references:

  • Create Variables in Agentforce Builder https://help.salesforce.com/s/articleView?id=ai.agent_builder_variables_create.htm&language=en_US&type=5
  • Variables https://help.salesforce.com/s/articleView?id=ai.agent_parent_variables.htm&language=en_US&type=5
  • Create a Filter to Control Access to Subagents and Actions in the Legacy Builder https://help.salesforce.com/s/articleView?id=ai.agent_asset_filters.htm&language=en_US&type=5

Key takeaways

  • Variables store and reuse values across instructions, filters, expressions, and action inputs.
  • Filters make an asset available only when its configured conditions are met.
  • Validate the data source and timing for variables that control sensitive actions.

Check your knowledge

Answer exam-style AI Agents questions with answers and explanations.

Practice AI Agents
Finished this lesson? Mark it complete to track your progress.

Ready for the real exam?

Take the timed Salesforce Agentforce Specialist simulator: same number of questions, same time limit.

Get Complete Access