What Are Topics, Context/Custom Variables, and Event Logs in Agentforce Agents in Salesforce?

Published on: 7/7/2025

What Are Topics, Context/Custom Variables, and Event Logs in Agentforce Agents in Salesforce?

What Are Topics, Context/Custom Variables, and Event Logs in Agentforce Agents in Salesforce?

To make these agents intelligent and effective, Agentforce uses a few key building blocks: Topics, Context/Custom Variables, and Event Logs.

 

What is a Topic in Agentforce?

A Topic is the foundation of how your Agentforce agent understands and handles user intent. Think of a Topic as a container that defines a specific capability or use case your agent can manage—like checking order status, resetting a password, or updating account information.

Each Topic contains:

  • Classification & Scope
    This defines when the Topic should be triggered based on the user’s input and limits what the agent is allowed to do within that Topic.
  • Instructions
    Textual guidance that helps the agent respond appropriately. You can define tone, behavior, constraints, or best practices—like:
    • "Be formal and concise"
    • "Only show shipping info"
    • "Confirm the user’s identity before proceeding"
  • Actions
    These are the operations your agent performs once the Topic is matched. Actions can include:
    • Running Salesforce Flows
    • Invoking Apex classes
    • Making API calls
    • Querying records
    • Using prompts to generate AI-driven responses

Why Topics Matter:

They give structure and intent to your agent. Without Topics, the agent wouldn’t know how to react to user inputs or what tasks it should perform.

 

What Are Context and Custom Variables?

To make conversations intelligent and adaptable, Agentforce agents use variables—both system-driven (context) and user-defined (custom).

Context Variables

These are system-generated or session-specific variables that store dynamic information throughout the interaction. They help the agent remember:

  • User IDs
  • Case numbers
  • Email addresses
  • Choices the user made earlier

Example: If a user says “What’s the status of my last case?”, a context variable like MessagingUserID can fetch for recent cases and fetch needful inputs and respond correctly.

Custom Variables

You can define your own custom variables to store and manage specific data points relevant to your use case.
These variables allow deeper personalization and more complex flows by capturing unique session data.

Example: A custom variable like isEscalated can be used to identify whether the customer’s most recent case was escalated. If this variable is set to true, the agent immediately prioritizes the interaction, skips standard troubleshooting steps, and routes the chat to a human agent—ensuring faster resolution.

Topic Filters Based on Variables

Variables aren’t just for memory—they also control logic. You can use filters on Topics to determine whether a Topic should be triggered only when a specific variable is present or has a certain value.

Example: Only trigger a “Reset Password” Topic if the userVerified variable is true.

 

What is the Event Logs Section?

The Event Logs section provides a detailed timeline of everything that happens during a conversation. It’s like an audit trail or debugger for your agent.

Event Logs help you:

  • See which Topic was triggered
  • Track each Action that was executed
  • Monitor variable values throughout the conversation
  • Understand why something didn’t happen (e.g., a Topic didn’t match, or a Flow didn’t run)

Why Event Logs Are Useful:

  • Debugging: Quickly find and fix errors in how your agent handles requests.
  • Testing: Monitor the flow of conversation during development.
  • Optimization: Refine how your agent behaves by reviewing real session behavior.

 

Putting It All Together

Let’s imagine a customer says, “I need to change my email address.”

  1. The agent uses classification to match this to a “Change Contact Info” Topic.
  2. That Topic contains Instructions to be cautious and confirm the user’s identity.
  3. The agent checks a context variable like userVerified. If not verified, it launches a verification Topic.
  4. Once verified, the agent executes an Action (e.g., call a Flow to update the email).
  5. The entire interaction is logged in Event Logs, which admins can review later to ensure the process worked as expected.

 

Conclusion

Topics, context/custom variables, and event logs are the core pieces that make Agentforce agents smart, responsive, and transparent. They help your agents:

  • Understand intent
  • Remember important details
  • Take action appropriately
  • And provide a full trace of what happened during any session