After creating and deploying an Agent in Salesforce, we need to train the agent with natural language so that when a user or customer asks the agent a query, the agent should display the result. This can be done using topics, instructions, and actions, which are the building blocks of agents in Salesforce.
In this tutorial, we will learn about the building blocks of Agents in Salesforce. In that, I will explain why the building blocks are necessary and how to create custom topics, instructions, and actions in Salesforce Agentforce.
Building Blocks of Agents in Salesforce
In Salesforce, building blocks of Agents refer to the reusable components and elements that help design and automate AI-driven processes within Salesforce agents. These building blocks are essential for creating intelligent and automated workflows that can interact with Salesforce data, enhance customer experience, and provide insights.
These agents are built using three components: Topic, Instructions, and Actions. These are specific tasks or actions that the agent performs, like retrieving data, sending an email, or updating a record. Custom actions are often integrated with the agent’s logic to automate business processes.
Because of the building blocks, the agent understands and processes information, communicates naturally with the user, and takes action to perform specific tasks. When we create a new agent in Salesforce, we get access to standard topics and actions.
In Salesforce, an org can have multiple agents deployed on different channels to perform different tasks. The Salesforce Agent helps internal Salesforce employees in their daily work, and the Community Agent helps external users by solving their queries.
Every organisation is special and has requirements specific to its business use case. To handle such requirements, we will have to create custom actions and assign them to the topics that will be assigned to the agents so that the agents will be able to perform the task.
Requirement of Creating Topics, Instructions, and Actions in Salesforce Agentforce
In this organization, we would like to give our agents the ability to answer queries when customers ask about the priority of their accounts. Therefore, the expectation is that the customer will provide us with the account number they received via email or message.
These AI agents, which may be deployed on a customer community portal, will be able to take the Account Number and inform the customer of their account’s priority.

Create Topics, Instructions, and Actions in Salesforce Agentforce
In the Agentforce building blocks of agents, we have the following functionalities.
The following are ways to create custom actions in Salesforce:
- Apex: Salesforce programming language.
- Flows: No code Salesforce automation tool.
- Prompt Template: Reusable prompts written with natural language.
- External Services: No-code connection to external API.
So, here, we will create a custom action. This action’s job will be to answer queries related to soft drink order status. Here, we will see all the steps required to build an agent action and topic and then assign it to an agent.
Actions in Salesforce Agentforce
The work behind the scenes of an agent is due to actions. Actions actually perform the task, such as creating a draft order, booking an Appointment, or fetching account details, etc.
We will create standard and custom actions in the system according to the organisation’s needs, which will solve a particular task. The custom actions can be created using Flows, Apex, and prompt templates.
- Standard Actions: When we enable the agent, the standard actions provided by Salesforce are already in place.
- Custom Action: Salesforce users create custom actions according to business needs to solve tasks specific to the organisation.
Create Actions in Salesforce Agentforce
Here, we will use the Apex class to create a custom action.
1. Create Apex Class:
Now, let’s create an Apex class that will take the account number and return the account priority to the agents.
The Apex class CustomAction is created to return the priority of an account when a user provides an account number. First, we declared the @InvocableMethod. This method makes this class available for use as a custom action by AI agents.
When we use this Apex class as a custom action in Agent Builder, that custom action will have a required field called Instruction, which is very important. So, the description will be used as an instruction.
Then, the static method (getPriority) takes input from a list collection of account numbers (accNumber) and returns a list of strings (the priority of the account).
In the SOQL query, we passed the user’s account number to retrieve the account priority value. Then, it returns the Account_Priority__c value in a new string list.
public class CustomAction {
@InvocableMethod( label = 'Account Priority'
description = 'Return the priority of an accountnumber, when user ask for it,
for example user can say what is priority of my account xyz' )
public static List<String> getPriority( List<Integer> accNumber ){
Account acc = [Select ID, Name, Account_Priority__c From Account Where
Account_No__c=:accNumber[0] ];
return new List<String> { acc.Account_Priority__c };
}
}2. Create a New Custom Action For the AI Agent
In the above step, we created the class that actually executes the query in the backend. Now, we need to create an action in Salesforce for an agent. To do that, in Quick Find, search for Action Agent and click on it.
There, you will see the standard actions created by Salesforce. To create a new one, click the New Agent Action button.

Fill in the details below:
- Referenced Action Type: First, you will only see this field. We need to select Apex because we created an action in the Apex class. As you choose the Apex, another field will be populated.
- Referenced Action Category: In this field, we need to select Invocable Methods.
- Referenced Action: Here, select the label that you provided in the Apex class. In our apex class, we provided Account Priority as a label.
- Then, the Agent Action Label and API Name will automatically populate.

Now, you will see that the Agent Action Instruction field is auto-populated, and this information comes from the description field in the Apex class. This field is crucial because it is what the Atlas reasoning engine uses to determine whether this action will effectively solve the particular task.
In the Loading Text, provide the text that will display when the agent searches the details of your query.
In the Input section, we can see that the Apex method was expecting the account number. Then, we have to instruct the Atlas reasoning engine on what information should be passed here.
Then, in the instruction’s Output section, we instruct the agent that when you invoke this Apex class, passing the account number, you will receive some output, and we specify what to do with that output.
After that, click the Finish button, and the action will be created.

Now you can see the custom action has been successfully created.

Topic in Salesforce Agentforce
The topic defines the work these AI agents will do, so each topic defines the agent’s jobs. Here, we defined the job in natural language. Unlike chatbots, which involve defining a decision tree, these topics comprise a set of instructions and actions that perform a specific task.
When creating a topic, we define the instructions the agent will follow if it chooses this topic for the current request.
Create Topic and Assign Custom Action to Topic
In the above steps, we have created a new custom action. Now, we need to assign the created action to the topic.
Navigate to the Agents and select any agent for which you want to assign a created custom action. Here, I have selected Coral Cloud Agent.

After that, click on the Open in Builder button to assign the action.

Here, this agent does not have any topic, and we know that the topic is the one that defines what an agent is going to do. The topic contains instructions and actions. So we are going to assign the created action to the topic.
To create a new topic, click the New dropdown button and select New Topic.

Fill in the topic details as per your requirements. Below, I have shown what should be provided to create a topic.
- Topic Label: Provide the name of this topic, and the name should be specific.
- Classification Description: This topic helps users find the account priority of accounts when they ask by providing an account number.
- Scope: Here, we need to specify the limit of our topic. For example, this topic is for account information, and if the user searches for contact information, then the Atlas engine will understand that by using this scope, the agent will not get results in this topic.

Instructions
The instructions are the guardrails, or these are the things that help the agent perform their job. Here, you need to provide instructions to the agent, and you can add multiple instructions by clicking the Add Instruction button.
After adding the instructions, click the Next button to proceed.

Now, we need to select the actions for this topic. So, we created the Account Priority action and selected it. If you think your topic will require any other action, then you can select that as well.
After that, click the Finish button.

Now, you can see that one topic has been added to the agent builder. This allows us to create multiple topics and assign multiple actions for one topic in Salesforce.
As you keep on adding topics and custom actions to this agent, it will be able to perform more tasks. But for now, it can only perform account priority inquiries.

After adding the Topic, Action, and the Instruction, we are ready to use this agent. Now in the Conversation Preview, I have asked a query or question about the priority of account no 1001.
As a response, you can see it returns the ‘Low‘ priority for the 1001 account number. Also, on the left side, you can see a user prompt that we asked, then the Atlas engine selects the topic and action that need to be performed, and the input and output result is displayed.

In the account object, you can also see that for the 1001 account number, the priority is ‘Low’.

Instructions in Salesforce Agentforce
Instructions are kind of rules that the agent should follow while solving customer queries. For example, we can give instructions that do not accept negative values, define a rule that the zip code length should be 5 digits, require the user to provide the order number, etc. Instructions are the guardrails that ensure that the Agent will perform the task within the boundaries that we have defined.
For example, for asset installation, we need to define the required information in the instructions, and creating an installation request is the actual action. However, we can define how to perform the action using instructions.
In this way, we can create actions, assign them to topics, and create instructions for AI agents in Salesforce.
Conclusion
I hope you have got an idea about the building blocks of Agents in Salesforce. In that, we have seen why the building blocks are necessary and how to create custom topics, instructions, and actions in Salesforce Agentforce.
To create the action here, we used the Apex class. Then, we assigned the created action to a topic and, by adding instructions, guided the agent to return the answer that the user would ask.
You may like to read:
- Create and Deploy Agentforce For Service in Salesforce
- Configure Agentforce for Customer Service in Salesforce
- Atlas Reasoning Engine in Salesforce Agentforce
- Invoke Flows From Prompt Template in Salesforce Agentforce
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.