Sub topic 8
Actions: what the agent can do
This chapter assumes you know basic Salesforce objects and fields, can find your way around Setup, and have a rough idea of what a large language model does. It also assumes you have read the earlier chapters on topics and topic instructions.
What an action is
An action is a unit of work that an agent can run. A topic decides which job the agent is doing. Instructions guide its reasoning. Actions are how the agent reads data, changes data, or produces content.
An agent cannot query an order or update a case by itself. It can only reason in language. When a task needs a real result, the agent calls an action, receives the output, and uses that output in its reply.
An action is attached to a topic. The agent can only use the actions assigned to the topic it has selected. This keeps each job small and limits what the agent can touch.
How the agent uses an action
The agent follows the same loop each time it needs an action:
- It classifies the request and picks a topic.
- It reads the topic's instructions and the list of actions in that topic.
- It chooses an action based on the action's name and description.
- It fills the action's inputs from the conversation, or asks the user for missing values.
- The platform runs the action and returns the outputs.
- The agent writes a reply based on those outputs.
Steps 3 and 4 are where most problems appear. The agent picks actions by reading text, so the quality of that text decides how well it chooses.
What an action contains
Every action has the same basic parts, whatever it is built on.
| Part | Purpose |
|---|---|
| Name | A short label that tells the agent what the action does. |
| Description | A sentence on when to use the action. The agent relies on it to choose. |
| Inputs | Values the action needs, such as an order number. |
| Outputs | Values the action returns, such as a status. |
| Implementation | The Flow, Apex method, prompt template, or standard action that does the work. |
The earlier Order Status example uses an action named Get Order Status. Its input is an order number and its output is a status string. Its description is "Looks up the status of an order by its order number." That description tells the agent this action fits a status question and does not fit a refund.
Read actions and write actions
Actions fall into two groups by effect.
- Read actions return information and change nothing. Looking up an order status is a read action.
- Write actions create, update, or delete records, or send messages. Changing a shipping address is a write action.
Treat these groups differently. A wrong read action costs a bad answer. A wrong write action changes real data. Give write actions narrow inputs, explicit instructions about when they may run, and confirmation steps where the change is hard to undo.
Common errors
- Vague descriptions. "Handles orders" does not help the agent pick between three order-related actions. State what the action does and what it needs.
- Missing or unlabeled inputs. If the agent cannot tell what an input means, it may guess or fill it with the wrong value.
- Too many actions in one topic. A long list makes selection less reliable. Split the topic if actions serve different jobs.
- No handling for empty results. If an action returns "Not found" and the instructions say nothing, the agent may invent an answer. Say what to do in that case.
Where this leads
Actions can be built in several ways: Flow, Apex, prompt templates, and standard actions. The next chapter compares them. After that, you will look at describing inputs and outputs and at writing instructions that tell the agent when to use each action.
Exercise
A topic contains an action named "Update Order" with the description "Works with orders." A customer asks where their package is, and the agent runs the action. Name two problems in the action definition that could cause this and say how to fix them.
Show answer
The name and description are too vague, so the agent cannot tell that the action changes data or when it applies. Rename it to say what it does, for example "Change Shipping Address", and rewrite the description to state its purpose and inputs. It is also a write action in a topic meant for status lookups. Move it to a topic where changes are in scope, and add an instruction on when it may run.