Dylan Andersen's DocsDylan Andersen's Docs
Working with AgentforceThe New Agentforce BuilderAgent Script

Smooth Operators

Operators in Agent Script allow you to compare values, combine conditions, and perform arithmetic

Operators

Operators in Agent Script allow you to compare values, combine conditions, and perform arithmetic. These are used in conditional expressions and variable assignments.

Operators hero

Comparison Operators

OperatorDescriptionExample
==Equal to@variables.count == 10
!=Not equal to@variables.status != "done"
<Less than@variables.age < 18
<=Less than or equal@variables.score <= 100
>Greater than@variables.count > 0
>=Greater than or equal@variables.total >= 50
isIdentity check@variables.value is None
is notNegated identity@variables.data is not None

Examples

# Equality
if @variables.status == "active":
  | Your account is active.

# Inequality  
if @variables.role != "admin":
  | You don't have admin access.

# Numeric comparisons
if @variables.balance > 0:
  -> run @actions.process_withdrawal

if @variables.attempts >= 3:
  -> transition to @subagent.lockout

# Null checks
if @variables.email is not None:
  -> run @actions.send_notification

if @variables.phone is None:
  | Please provide a phone number.

Logical Operators

OperatorDescriptionExample
andLogical AND@variables.a and @variables.b
orLogical OR@variables.x or @variables.y
notLogical NOTnot @variables.flag

Examples

# AND - both conditions must be true
if @variables.is_verified and @variables.has_payment:
  -> run @actions.complete_purchase

# OR - at least one condition must be true
if @variables.is_admin or @variables.is_moderator:
  -> set @variables.can_delete = True

# NOT - inverts the condition
if not @variables.email_confirmed:
  | Please confirm your email address.

# Combined operators
if @variables.is_logged_in and (not @variables.is_banned):
  | Welcome back!

if (@variables.role == "admin" or @variables.role == "manager") and @variables.is_active:
  -> run @actions.show_dashboard

Arithmetic Operators

OperatorDescriptionExample
+Addition@variables.count + 1
-Subtraction@variables.total - 5

Examples

# Incrementing a counter
-> set @variables.attempt_count = @variables.attempt_count + 1

# Calculating remaining attempts
-> set @variables.remaining = @variables.max_attempts - @variables.attempt_count

# Using in conditions
if @variables.balance - @variables.withdrawal_amount >= 0:
  -> run @actions.process_withdrawal
else:
  | Insufficient funds for this withdrawal.

Operator Precedence

When combining operators, use parentheses to ensure correct evaluation:

# Without parentheses - may not work as expected
if @variables.a or @variables.b and @variables.c:
  # This is evaluated as: a or (b and c)

# With parentheses - explicit and clear
if (@variables.a or @variables.b) and @variables.c:
  # This is evaluated as: (a or b) and c

Best Practice

Always use parentheses when combining and and or operators to make your intent clear.


Common Patterns

Range Checking

if @variables.quantity >= 1 and @variables.quantity <= 100:
  -> run @actions.process_order
else:
  | Please enter a quantity between 1 and 100.

Multiple Value Checking

if @variables.status == "shipped" or @variables.status == "delivered":
  | Your order is on its way or has arrived.

Conditional Variable Setting

if @variables.order_total > 100:
  -> set @variables.shipping_cost = 0
else:
  -> set @variables.shipping_cost = @variables.base_shipping + 5

Guard Conditions

before_reasoning:
  # Guard: ensure required data exists
  if @variables.customer_id is None or @variables.session_valid == False:
    -> transition to @subagent.authentication

On this page