Agent API versus custom agent actions
Key Takeaway
Ask who makes the call. Build a custom agent action when the agent needs to do something during a conversation. Use Agent API when an outside system, custom app, or background process needs to talk to the agent.
Agent API and custom agent actions both connect Agentforce agents to other systems, but they work in opposite directions. A custom agent action gives an agent something it can do, such as run a flow, call Apex, use a prompt template, or call an external service. Agent API is a REST API that lets an outside application or background process start a session with an agent, send it messages, and get its replies.
Who makes the call
To choose between the two, start by asking who makes the call.
If the agent needs to do something during a conversation, such as update a record or reach an outside system...
Build a custom agent action.
If an outside system, custom app, or background process needs to talk to the agent...
Use Agent API.
Agent API doesn't replace agent actions. The agent still runs its actions during an Agent API session.
A shipping company has an Agentforce agent that answers questions about deliveries. A customer in a chat asks where her package is. The tracking data lives in a carrier's system outside Salesforce. The agent itself has to fetch that data, so you build a custom agent action on an external service. Later, the company's warehouse system, which runs outside Salesforce, needs to send the agent a list of delayed orders every night and store the replies. Here the warehouse system makes the call, so it uses Agent API. During those Agent API sessions, the agent still runs its tracking action when it needs carrier data.