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

Lights, Camera, Action!

Actions define executable tasks that an agent can perform, including Flows, Apex classes, or Prompt Templates

Actions

Actions define executable tasks that an agent can perform. Actions can call Flows, Apex classes, or Prompt Templates. You define actions in a subagent's actions block and can invoke them deterministically or expose them as tools for the LLM.

Actions hero

Actions Overview

Actions can be invoked in two ways:

MethodDeterminismWhere DefinedWhen It Runs
Explicit callDeterministicreasoning.instructionsEvery time the subagent runs
As a toolNon-deterministicreasoning.actionsWhen LLM decides based on context

Action Definition

Complete Example

subagent order_tracking:
  actions:
    get_tracking_updates:
      description: "Retrieves tracking information for an order"
      inputs:
        tracking_number:
          type: string
          required: True
          description: "The order tracking number"
      target: flow://GetTrackingUpdates
      outputs:
        current_location:
          type: string
          description: "Current package location"
        delivery_date:
          type: date
          description: "Estimated delivery date"
      label: "Get Tracking Updates"
      include_in_progress_indicator: True
      require_user_confirmation: False

Action Properties

PropertyRequiredDescription
[action name]Identifier for the action (use snake_case)
descriptionDescription for LLM to decide when to call it
inputsInput parameters and their types
targetReference to executable (apex, flow, or prompt)
outputsOutput parameters and their properties
labelHuman-readable name (auto-generated from name if not specified)
include_in_progress_indicatorShow progress indicator when running (True/False)
require_user_confirmationRequire customer confirmation before running

Target Types

Actions can target three types of executables:

TypeFormatExample
Flowflow://Developer_Nametarget: flow://Get_Order_Status
Apexapex://Class_Nametarget: apex://OrderService
Prompt Templateprompt://Template_Nametarget: prompt://Customer_Greeting
actions:
  # Flow target
  get_order_status:
    target: flow://Get_Order_Status_Flow
    
  # Apex target
  process_payment:
    target: apex://PaymentProcessor
    
  # Prompt target
  generate_response:
    target: prompt://Customer_Response_Template

Input Parameters

Define what data the action needs to execute.

actions:
  create_case:
    inputs:
      customer_id:
        type: id
        required: True
        description: "Salesforce ID of the customer"
      issue_description:
        type: string
        required: True
        description: "Description of the customer's issue"
      priority:
        type: string
        required: False
        description: "Case priority level"
    target: flow://Create_Support_Case

Supported Parameter Types

TypeDescriptionExample
stringText values"Hello World"
numberFloating point numbers99.99
integerInteger values42
longLong integer values9223372036854775807
booleanTrue/FalseTrue
objectComplex JSON objects{"key": "value"}
dateDate (YYYY-MM-DD)2025-01-15
datetimeDateTime values2025-01-15T10:30:00Z
timeTime values10:30:00
currencyCurrency values100.00
idSalesforce ID"0015000000XyZ12"
list[<type>]List of any typelist[string], list[number]

Output Parameters

Define what data the action returns. By default, the agent remembers output information for the entire session.

actions:
  get_customer_info:
    target: flow://Get_Customer_Details
    outputs:
      customer_name:
        type: string
        description: "Full name of the customer"
        developer_name: "customerName"
      account_balance:
        type: currency
        description: "Current account balance"
        filter_from_agent: True  # Hide from agent context
      customer_data:
        type: object
        complex_data_type_name: "lightning__recordInfoType"

Output Properties

PropertyRequiredDescription
typeData type of the output
descriptionDescription (auto-generated from name if not specified)
developer_nameOverride the parameter's developer name
labelHuman-readable label (auto-generated if not specified)
filter_from_agentIf True, output is hidden from agent context
complex_data_type_name✅*Required for object type; specifies the type returned

Hiding Sensitive Data

Use filter_from_agent: True to exclude sensitive outputs (like SSN or internal IDs) from the agent's context while still making them available for processing.


Using Actions

Method 1: Deterministic Execution

Use run @actions.<action_name> in reasoning instructions to always run the action.

subagent verification:
  actions:
    send_verification_code:
      target: flow://Send_Verification_Email
      inputs:
        email:
          type: string
          required: True
  
  reasoning:
    instructions:
      if @variables.email_address is not None:
        -> run @actions.send_verification_code
        | I've sent a verification code to your email. Please enter it to continue.

Method 2: Reference in Prompt (LLM Decides)

Use {!@actions.<action_name>} in prompt text for the LLM to decide whether to run it.

reasoning:
  instructions: |
    Help the customer with their order.
    If they need tracking information, use {!@actions.get_tracking}.

Method 3: Expose as Tool

Define the action as a tool in reasoning.actions for the LLM to call when appropriate.

reasoning:
  instructions: |
    Help the customer track their order.
    Ask for the tracking number if needed.
  actions:
    - get_tracking_tool:
        description: "Get tracking info when customer provides tracking number"
        @actions.get_tracking_updates
        with:
          tracking_number: ...
        set:
          @variables.current_location: current_location
          @variables.delivery_date: delivery_date

Complete Example

subagent email_verification:
  description: "Verifies customer email address"
  
  actions:
    send_verification_code_action:
      description: "Sends a verification code to the customer's email"
      inputs:
        email:
          type: string
          required: True
      target: flow://Send_Verification_Code
      outputs:
        code_sent:
          type: boolean
        expiration_time:
          type: datetime
  
  reasoning:
    instructions:
      # Deterministically send code when email is available
      if @variables.customer_email is not None:
        -> run @actions.send_verification_code_action
        | I've sent a verification code to {!@variables.customer_email}.
        | Please enter the code to verify your email address.
        | If you didn't receive it, let me know and I can resend it.
    
    actions:
      # Also expose as tool so LLM can resend if needed
      - resend_code_tool:
          description: "Resend verification code if customer didn't receive it"
          @actions.send_verification_code_action
          with:
            email: @variables.customer_email

A More Salesforce-Flavored Action Bundle

This example is closer to what production Agent Script feels like in Salesforce: multiple actions, typed outputs, and a subagent that mixes deterministic execution with selective tool exposure.

subagent field_dispatch:
  description: "Creates or updates a field service dispatch plan"

  actions:
    get_work_order:
      description: "Load the work order and current status"
      inputs:
        work_order_id:
          type: id
          required: True
      target: flow://Get_Work_Order_Details
      outputs:
        account_name:
          type: string
        status:
          type: string
        service_territory:
          type: string

    get_technician_availability:
      description: "Returns available technicians and windows"
      inputs:
        service_territory:
          type: string
          required: True
      target: apex://TechnicianAvailabilityService
      outputs:
        available_slots:
          type: list[datetime]

    generate_dispatch_summary:
      description: "Summarize the dispatch plan for the customer"
      inputs:
        account_name:
          type: string
          required: True
        appointment_time:
          type: datetime
          required: True
      target: prompt://Dispatch_Summary_Template
      outputs:
        summary_text:
          type: string

  reasoning:
    instructions:
      -> run @actions.get_work_order
      -> run @actions.get_technician_availability
      |
      Help the customer confirm the best appointment window.
      Once they choose a slot, summarize the dispatch plan in plain language.

    actions:
      - dispatch_summary_tool:
          description: "Generate a polished dispatch summary after the customer picks a slot"
          @actions.generate_dispatch_summary
          with:
            account_name: @actions.get_work_order.outputs.account_name
            appointment_time: ...

Action Naming Rules

Action names must follow Salesforce developer name standards:

  • Begin with a letter (not underscore)
  • Alphanumeric characters and underscores only
  • Cannot end with underscore
  • No consecutive underscores (__)
  • Maximum 80 characters
  • Recommended: Use snake_case

On this page