Sub topic 1
How an Agent Uses Actions
Prerequisites
This chapter assumes you have the following:
- Basic familiarity with Salesforce Setup and Agentforce Builder.
- A working idea of what an Agentforce agent, topic, and action are.
- Working knowledge of Flow variables or Apex classes.
- Awareness that the agent uses a large language model (LLM) to decide what to do.
What an action is
An action is a unit of work the agent can run. It might look up a record, update a field, or call an Apex method. Actions are how the agent reaches your data and logic. The LLM can't query your org by itself. It can only call the actions you give it.
An action has three parts:
- Target: the Flow, Apex invocable method, or prompt template that does the work.
- Inputs: the values the target needs to run.
- Outputs: the values the target returns.
The agent never sees your code or your Flow elements. It sees the action's name, its description, and the labels, descriptions, and data types of its inputs and outputs. That text is the only picture of the action the agent has. The rest of this tutorial is about writing that picture well.
The reasoning loop
When a customer sends a message, the agent follows roughly this loop:
- It picks the topic that matches the request.
- It reads the actions available in that topic.
- It decides whether an action would help, and which one.
- It fills each input from the conversation. If a required value is missing, it asks the user.
- It runs the action.
- It reads the outputs and writes a reply.
Your definitions affect steps 3, 4, and 6. A vague description leads to the wrong action choice. A vague input leads to guessed values. A vague output leads to an inaccurate reply.
A concrete example
Suppose a customer writes: "Where is order 00000101?" The topic contains an action called Get Order Status. Its description says it looks up the status of one order by order number. Its input, Order Number, is described as the number the customer provided. Its outputs are Order Status and Result Message.
The agent matches the question to the action and takes 00000101 from the message as the Order Number. It runs the action, gets back a status such as Activated, and tells the customer.
Now suppose the customer writes only, "Where is my order?" The Order Number input is required and has no value. A good description such as "Ask the customer if it was not given. Do not guess." tells the agent to ask a question. A poor one such as "The id" gives it nothing to work with, so it may invent a value.
Common errors
- Wrong action chosen. Two actions have similar names or overlapping descriptions, and the agent picks the wrong one.
- Action never called. The description doesn't say when to use the action, so the agent answers from general knowledge instead.
- Guessed inputs. The input description doesn't say where the value comes from or what to do when it is missing.
- Misread outputs. Labels like "Result" don't say what the value means, so the agent describes it incorrectly or omits it.
Where this chapter fits
Later chapters cover each piece in detail: choosing a target type, writing metadata, designing inputs and outputs, handling errors, and testing. For now, keep one rule in mind. Write every name, label, and description as if it were the only documentation the agent will ever read, because it is.
Exercise
A customer asks, "Can you check my order?" without giving a number. The Order Number input is required. Name two things in the definition that determine whether the agent asks for the number or guesses one, and say what the agent does at that step of the loop.
Show answer
The input must be marked required, and its description should tell the agent to ask the customer if the value was not given and not to guess. At the input-filling step, the agent sees that a required value is missing and asks the user. With a vague description like "The id", it may invent a value instead.