Salesforce Developers Blog

Set Test Context in Agent Builder with Preview Conditions

Avatar for Charles WatkinsCharles Watkins
Learn how to simulate specific user contexts directly in Agent Builder to streamline your testing process and ensure robust agent behavior.
Set Test Context in Agent Builder with Preview Conditions
June 26, 2025
Listen to this article
0:00 / 0:00

Building and testing intelligent agents is key to delivering great experiences. However, thoroughly vetting your agent’s behavior across different scenarios can be a challenge. Manually providing specific contextual information, like the current app, record page, or user data for each test run in Agent Builder, is often tedious and time-consuming. Without this precise context, it can be difficult — if not impossible — to see how your agent will behave under specific scenarios and conditions.

This is where Preview Conditions in Agent Builder comes in. With preview conditions, you can define the exact environment that your agent needs for a specific test, directly within the builder, before you type a prompt. You can set details, such as the Salesforce app and page type that your agent is interacting with, the specific record it should focus on (like a Contact or Case), or even crucial customer-specific variables like language, email, or member ID for service agents. This setup simulates the live operational context right from the start of your test session.

Want to see this process, step-by-step? Watch the video above, where we demonstrate how to use preview conditions to test and develop both an employee agent and service agent.

About the author

Charles Watkins is a Lead Developer Advocate at Salesforce. You can find him on LinkedIn.

More Blog Posts

The Salesforce Developer’s Guide to the Winter ’25 Release

The Salesforce Developer’s Guide to the Winter ’25 Release

The Winter '25 release is here! In this post, we highlight what’s new for developers across the Salesforce ecosystem.September 03, 2024

Build Advanced Custom Agent Actions with Code

Build Advanced Custom Agent Actions with Code

Agentforce and its advanced custom agent actions can be created to customize agents using tools like Flow, prompt templates, Apex, and APIs.December 05, 2024

Write Better Agent Instructions with Agentforce AI Assist

Write Better Agent Instructions with Agentforce AI Assist

AI Assist is your intelligent generative AI partner in Agent Builder, helping you to create clear instructions for Agentforce.May 29, 2025