Sub topic 1
How agents, topics, and actions fit together
Prerequisites
This chapter assumes you know the basic Salesforce data model (objects, fields, records). It also assumes you have used Flow Builder (variables, elements, resources) and can find permission sets in Setup. You should have a general idea of what an AI agent is. You don't need to have built an Agentforce agent before.
The three building blocks
An Agentforce agent is made of three layers, and each one narrows what the agent does.
- Agent. The assistant that talks to a user. It has a role, a company-level tone, and a set of topics. A large language model (LLM) reads the user's message and decides what to do.
- Topic. A category of work, such as "Case Management" or "Order Questions". A topic has a description, instructions, and a list of actions. The agent first picks the topic that matches the request.
- Action. A single task the agent can run, such as "Get Case Status". An action can be a flow, an Apex method, a prompt template, or another supported type.
Think of the topic as a department and the action as one thing that department can do. The agent can only use actions from the topic it has selected.
What happens at runtime
Suppose a customer writes, "What's the status of case 00001026?"
- The agent compares the message with the topic descriptions and chooses "Case Management".
- It reads the descriptions of the actions in that topic and picks "Get Case Status".
- It fills in the action's inputs from the conversation. Here,
caseNumberis00001026. If the user had not given a number, the agent would ask for it. - Salesforce runs the flow with those inputs.
- The flow returns its output variables, such as
caseStatus. - The agent writes a reply to the user based on the output.
Only step 4 is deterministic. Steps 1 to 3 and 6 depend on the LLM's reading of text you wrote. This is why the names and descriptions in later chapters matter so much.
Why use Flow for actions
Flow is a good fit when the work is a defined sequence of data steps: look up a record, check a condition, update a field. The logic runs the same way every time, and admins can build and maintain it without code. The agent decides whether to call the action. The flow decides exactly what happens when it runs.
The following table summarizes who controls what.
| Concern | Controlled by |
|---|---|
| Which topic handles the request | The agent, using topic descriptions |
| Which action to call | The agent, using action descriptions and instructions |
| What values go into the action | The agent, using input descriptions and the conversation |
| What the action does with data | Your flow |
| What the user is told | The agent, using the flow's outputs |
Common mistakes at this stage
- Putting too many actions in one topic. The agent has more choices to confuse. Keep topics focused.
- Overlapping topics. If two topics have similar descriptions, the agent may pick the wrong one.
- Assuming the agent follows the flow's logic. It only sees inputs and outputs. If a decision matters, build it into the flow.
Exercise
A user asks an agent about a refund. The agent runs the right flow, but the flow's logic checks eligibility incorrectly. Is the problem in the topic, the action, or the flow, and why?
Show answer
The flow. The agent selected the correct topic and action, so the LLM-driven steps worked. The eligibility check is deterministic logic inside the flow, which is the part you control directly. Fix the decision element in the flow.
Exercise
Name the two things the agent uses to decide which of several actions in a topic to call.
Show answer
The action's name and its instructions or description. The agent also uses the user's request, but it can only compare that request against the text you provide for each action.