Agentic Architecture 101: Custom Topics, Actions, and Best Practices

Learn how to make decisions on effective Topics and Actions in Agentforce to power smarter AI Agent interactions. This guide covers key implementation strategies and best practices to build a strong architectural foundation for your Agentforce setup.

When it comes to getting the most out of Agentforce, the real magic happens under the hood and more specifically, in how you design Topics and configure Actions for the Agents you’ve built. These aren’t just check-the-box setup tasks. They’re the logic and structure that guide every interaction your Agent handles. In this post, we’ll walk through the mechanics of setting up custom Topics and Actions inside Salesforce, highlight what actually matters during configuration, and share some best practices based on our own implementations—because getting it almost right is usually what breaks things later.

Topics

Topics are the first layer in an Agent’s decision-making. Every time the user makes an utterance, the Agent evaluates what topic it belongs to. A topic has three important components, all of which are evaluated by the AI:

  1. Classification Description: How an agent should determine when to use this topic
  2. Scope: A high-level description of what the agent can do in this topic
  3. Instructions: Specifics on what, when, and how an agent should perform certain actions once its decided to use this topic

You can create new Topics from the Topics tab on the Agent’s page in Setup…

…or from the Topics section of Agent Builder.

You can add new or existing Actions to a Topic.

You also don’t necessarily need to have any Actions on a topic. A common use case for this is where you want strict control over how an Agent answers a particular question or set of questions. You don’t want it to search through Knowledge and then summarize a relevant article; you want the same “hard coded” answer every time.

In this case, you can create a Topic for this scenario, and provide instructions on exactly what you want the Agent to say.

Actions

Actions are how an Agent interacts with the rest of Salesforce. Any kind of Read, Create, Update, or Delete is done through an Action.

There are a few types of Agent Actions:

  1. Flow
  2. Apex
  3. Prompt Template
  4. API
  5. Predictive Model
  6. Service Catalogue Item

Flow Actions can call any “Autolaunched (No Trigger)” Flow.

Variables that are marked as Available For Input, or Available For Output in the target Flow become the Inputs and Outputs for the Action.

When you create the Action, you will need to provide instructions for the action as a whole, as well as for each input and output.

The agent is pretty smart at determining what information from the conversation to plug in to each input, but you sometimes may need to provide explicit instructions on “this information goes into this input” on the topic-level instructions too.

Another important thing to understand is Session Variables. These contain information from the Messaging Session. The Messaging Session ID is generally the most important information in here, and you will need to pass it in to Flows which create Cases, in order to link the Messaging Session to the Case.

The Messaging Session can also be used to carry information from a Pre-Chat form, or about a logged-in portal user.

*Note: Not all the Messaging Session fields are automatically included in the Session Variables. You may need to use the Edit Included Fields button to add other fields to the Session Variables

In the following example Flow, the Agent sets the CaseSubject, CaseDescription, InputEmail, and MessagingSessionID inputs.

The Flow queries Contacts to see if one already exists with the email address provided.

If a Contact is found, a Case is created with that Contact linked. If no Contact is found, a Case is created with the provided email address entered in the SuppliedEmail field normally used by email-to-case.

The Case Number is queried from the just created Case and assigned to the outputText variable, and the Messaging Session with an ID that matches the MessagingSessionID variable is linked to the created case.

Prompt Template works similarly. They execute a Prompt Template, passing certain information into inputs, and getting an output once the Template has been run.

A Prompt Template is a much longer and more complex set of instructions sent to an LLM for analysis. Templates can include merge fields and even search results. 

The most common use case right now is creating a custom knowledge base lookup action. The standard “Answer Questions with Knowledge” action actually uses a standard Prompt Template, but that template can be overridden, and you can also create custom actions that call custom templates.

Apex Actions can call any Apex class with an invocable method. On the Apex side, this works just like invocable methods for Flows. The parameters in the method will define the inputs, and whatever the method returns is the output. Remember that the inputs and outputs must be collections, even if the variables are singular in practice. 

Best Practices

  • Currently, an Agent can only perform a single action for every user utterance. Chaining actions together is not currently possible. This capability is supposed to be coming some time around Spring 2025, so for now, keep this in mind when designing your solution. 
  • If you add or change the input or output variables on a Flow, the inputs and outputs on the Agent Action do not update. You will need to re-create the Action from Scratch. For this reason, we suggest including version numbers in your Action names for now. 
    • There is a way to update the Agent Action using the CLI.
  • In practice, we have found that it is possible to end a conversation from the Agent’s side by instructing it to “execute the End Conversation action”. 
    • This does work, but it seems to be unsupported functionality, and is very picky on precise wording in the instructions. Use caution and test thoroughly if using this technique. 
  • The order you enter instructions in isn’t necessarily respected when the instructions are given to the LLM. If you have certain steps the Agent must complete in sequence, include them all in one instruction block.
  • Consider having immediate requests from the User to create a case route through your Knowledge topic first instead. Have the Agent ask the User what the subject of the case will be, but instead of creating the case right away, first perform a knowledge search, and ask if the results answer the user’s question. If not, go ahead and create a case. If it does, we just diverted a case from being created.

AI in Salesforce—especially when it comes to Agentforce—is still evolving fast. And like most teams out there, we’re learning as we go. The Lane Four advantage? We’re moving quickly, implementing what we know, testing constantly, and doing our best to share what we’re seeing in real time. If things still feel a bit fuzzy, it’s because the space is changing—fast. But we’re committed to moving just as quickly, being transparent along the way, and doing everything we can to stay one step ahead. Thinking the same way and curious about what makes the most sense for your AI strategy? Let’s talk.

Let's chat!