Getting Started

  • What is Trailhead
  • myTrailhead
  • Trailblazer Community
  • Career Growth

Learn

  • Trails
  • Trailmixes
  • Modules
  • Projects

Credentials

  • Superbadges
  • Certifications
  • Maintain Certifications

Salesforce

  • Salesforce.com
  • AppExchange
  • Developers
  • Help Portal
© 2026 Salesforce, Inc. All rights reserved. Privacy Terms of Use Trust Accessibility Cookie Preferences
SalesforceTrailhead
  • Today
Agent Customization with Apex

Script Deterministic Agent Steps

+400 Points~10 minsHands-On Challenge
Agent Customization with ApexScript Deterministic Agent Steps

Org:Mindful Goat Playground

Topics

  • Why Deterministic Steps Matter
  • Write a Script
  • Test the Script
  • Resources

Looking for help?

Explore Help ResourcesShare Your Feedback
Learning Objectives

After completing this unit, you'll be able to:

  • Explain why some steps must be deterministic.
  • Script a fixed sequence with agent script.

Why Deterministic Steps Matter

Reasoning is flexible, which is usually what you want. But some steps must run the same way every time: verifying identity before sharing account details, or applying a discount rule. Agent script lets you pin those steps down while the agent stays conversational around them.

Note
Think of agent script as guardrails with an order. The agent still chooses words; the script decides the sequence.

Write a Script

  1. Open your agent and select the Account Inquiries topic.
  2. Add an agent script that runs Verify Identity before any action that reads account data.
  3. Save and activate the agent.
when topic == 'Account Inquiries':
  require action 'Verify Identity'
  then allow actions ['Get Balance', 'Get Recent Orders']
Check ChallengeDemo check

Test the Script

In the Agent Builder preview, ask for an order history without verifying. The agent should ask you to verify first, every time.

Check ChallengeDemo check

Resources

  • Salesforce Help: Agent Script
Previous unitWrite an Invocable Apex ActionBack to badge Agent Customization with Apex