In Salesforce, the Agentforce (Default) agent, which is a type of Employee, is going to retire soon because Salesforce is replacing it with the new Employee Agents.
For that, Salesforce has provided a new Agentforce Employee Agent, which we can set up and use. At our company, we create our own Employee Agents and assign them to the appropriate users.
After creating the Employee Agent, we need to assign actions to the agent so that the AI agent can perform tasks in response to requests raised by Salesforce users.
In this article, we will learn how to create & assign custom actions to AI agents in Salesforce Agentforce.
In this, I will explain why we need to create a custom action, how to create it, and how to assign it to an Agentforce Employee agent in Salesforce.
Why do We Need to Create & Assign Custom Actions to an AI Agent in Salesforce Agentforce?
In the screenshot below, you can see that we have activated the Agentforce Employee Agent, named it Sales Agent, and assigned it to users in Salesforce.

After that, when you open Agentforce and give a prompt to create a Task for an Account record and assign it to the record owner, you can see that the AI Agent is unable to create the Task for the Account.
This happens because we haven’t created a custom action for creating a Task and assigning it to the Employee Agent. Since the agent doesn’t have this action configured, it cannot perform the task when the user gives this prompt.

Build an Action for Task Creation Using Flow & Assign to Agentforce Employee Agent
In the next step, we will build a custom action using Salesforce Flow and assign it to the AI Agent. This will enable the agent to automatically create a task whenever the user requests one.
Create a Flow in Salesforce to Create an Agent Action in Salesforce
To create the flow, go to Setup -> in Quick Find search for ‘Flows‘ -> click the New Flow button -> select Start From Scratch -> Autolaunch Flow(No Trigger) -> Create.

Important: To use the flow as an action for the AI agent, we must select 'Autolaunch Flow (No Trigger)'; except for this flow, no other flow can be used as an action for an agent in Salesforce Agentforce.1. Create a Variable in Flow: Take the Input and Display Output
First, we need to create a variable from a New Resource so that we can take input from the user whenever they provide the Account Name to pass the flow. Then the flow will automate the process for that record.
As you click the Resource Type dropdown field, you will see various resources, such as Variable and Text Template. Here, we need to select the Variable.
Now we need to provide the details for the following fields:
- API Name: I have provided the name as RelatedId, which will accept the Account Name that the user has provided.
- Description: This description will be reflected in the Agentforce builder as an instruction for the agent when we assign the action to them.
- Data Type: The data type will be Text.
- Availability Outside the Flow: We must check the Available for input option. So that this variable can accept the Account name.

Again, we need to create another variable to accept the task subject from the user, and the flow will pass this subject to the task record. Here, also Availability Outside the Flow, we need to set it to ‘Available for input‘.

Now, when the Task record is created for the Account and assigned to the Account Owner, we need to send a response back to the user with the generated Task Record ID.
To do this, we will create a variable to store the created Task Record ID and mark it as Available for Output. This allows us to pass the variable to the AI Agent so that the agent can display the created Task Record ID to the user.

2. Create Record Element: Create Records for Task Object
Then, to assign the task to the record owner, we need to add the Create Record element. Provide details; in the object, select the Task object.

Below, I have explained Set Field Values for the Task:
- Due Date Only: For the due date, I have assigned a formula that sets the due date to be within the next 3 days after the task is assigned.
- Assigned To ID: Here, we need to specify to whom we want to assign this task, and I assigned it to the current user.
- Subject: The subject will be whatever he has sent, and the related ID will become the whatId
After that, we set the TaskId variable to be available for output, added it here, and stored the ID of the created task record. That means it will be displayed as an output field on the custom action.

After creating the flow, save it and ensure it is activated before using it as a custom agent action in Salesforce Agentforce.
Create a Custom Action For Agent Using Flow in Agentforce
Now, we will create a new Agent custom action so that when the user asks any query or question, the agent takes action to perform tasks and responds to the user.
For that, go to Setup. In the Quick Find, search for Agentforce Assets. Click on New Agent Action.

Fill in the details below:
- Referenced Action Type: Previously, we selected Apex; now, as we are creating actions using flows, we need to choose Flow.
- Referenced Action: Here, select the label you provided in the auto-launched flow we created.
- Then, the Agent Action Label and API Name will automatically populate.
Then click the Next button to proceed.

So here, we need to provide instructions to the agent. In Agent Action Instruction, I have provided instructions to the agent so that whenever the agent gets such a prompt, it will be easy for the agent to understand that this action will solve the exact same requirement.

Again, we have an input field and an output field. Here, too, we must provide the instructions. Then click the Finish button.

In this way, we can create an action using Salesforce flow in Agentforce.
Assign Action to AI Agent in Salesforce Agentforce
Now, let’s assign the created custom action to an agent. For that, navigate to the Setup -> In Quick Find, search for the Agentforce Agents -> Select the Agent for which you want to assign a custom action.
Here, I have selected ‘Sales Agent,’ which is an Agentforce Employee Agent. -> Then click on the Open in Builder button to add an action.
After that, select the Topic to which you want to add the custom action. Then click This Topic’s Actions tab, click the New button, and select the Add from Asset Library option to choose the action that we created.

Then, select the action you want to assign to this agent. You can also select multiple actions, including both standard and custom options. Then click the Finish button.

You can see that the action has been assigned to the Sales agent, which means that his agent should now create the task when any Salesforce user raises a request.

Proof of Concept
After assigning the custom action to the agent, I again asked the agent to create a task for the XYZ account with the subject ABC. You can see how the agent responded to the user with the created Task ID.

As I navigate to the Task object, a new record has been created with the values we provided in the prompt and the auto-launched flow.

In this way, we can create custom actions using flow for Agentforce in Salesforce to automate any task when the agent gets such a prompt.
Conclusion
I hope you have an idea about how to create custom actions using the flow for Agentforce in Salesforce.
Using the use case, I have explained what a custom action is, which flow supports creating custom agent actions, how to create a flow, how to create a new action, and how to assign custom actions to agents in Salesforce after creating them.
You may like to read:
- Call Apex Methods from LWC Using @AuraEnabled in Salesforce
- Assign Record Summary Prompt Template to AI Agent in Salesforce Agentforce
- Invoke Agentforce Prompt Template From Salesforce Flows
- Transfer Customer Request From AI Agent to Human Agent in Salesforce Agentforce

Shubham is a Certified Salesforce Developer with technical skills for Building applications using custom objects, approval processes, validation rule salesforce flows, and UI customization. He is proficient in writing Apex classes, triggers, controllers, Apex Batches, and bulk load APIs. I am also familiar with Visualforce Pages and Lighting Web Components. Read more | LinkedIn Profile