Sub topic 1
Where actions fit in an Agentforce agent
Overview
An Agentforce agent does two kinds of work. It decides what to do, and then it does it. Topics and instructions guide the deciding. Actions do the work. This chapter places actions in that structure so the later chapters can add a prompt template as one kind of action.
By the end of this chapter you should be able to:
- Describe the parts of an agent and which part chooses an action.
- Compare a prompt template with agent instructions and with other action types.
- Explain what happens, step by step, when a user message leads to an action.
Prerequisites
This chapter assumes you have the following:
- The basic Salesforce data model: objects, fields and records.
- Some familiarity with Setup and permission sets.
- A rough idea of what an Agentforce agent is and what a topic is.
- Awareness of how prompting a large language model (LLM) works. An LLM is a model that generates text from a text prompt.
You do not need to have built an action before. You do not need Flow or Apex skills yet.
The parts of an agent
An agent is built from a small number of pieces. The names in the Setup UI can change between releases, but the structure stays the same.
- Agent. The overall assistant. It has a role, a company description, and a set of topics. It also has a channel it serves, such as a messaging window or an employee-facing surface.
- Topic. A bundle for one kind of job, such as "Case Hand-off" or "Order Status". A topic has a classification description, a scope, instructions and a list of actions.
- Instructions. Natural-language guidance inside a topic. They tell the agent how to behave and when to use which action.
- Action. A unit of work the agent can run. An action takes defined inputs and returns defined outputs.
- Reasoning engine. The LLM-driven component that reads the conversation, picks a topic, picks actions and writes the reply.
The key split is this. Instructions and descriptions are read by the reasoning engine, which interprets them with some variability. Actions are executed by the platform, with defined inputs and outputs. When you decide where a rule belongs, ask whether it is guidance or work.
How a request reaches an action
Consider a user who writes, "Can you summarize case 00001234 for my call?" The agent processes this in roughly the following order.
- The reasoning engine compares the message with each topic's classification description and scope, and selects a topic.
- It reads the topic's instructions and the descriptions of the topic's actions.
- It decides whether an action is needed. If it is, it fills the action's inputs from the conversation. It may ask the user for a missing value.
- The platform runs the action and returns the outputs.
- The reasoning engine uses the outputs, together with the instructions, to write the reply.
Steps 2 and 3 are the point where your wording matters. The agent can only call actions that are attached to the selected topic. If the action is not in the topic, the agent cannot call it, however good the instruction is.
Action types
An action is a wrapper around some capability. The wrapped capability can be a Flow, an Apex method, a prompt template, or another supported target such as an API call. The agent treats them uniformly, because each one exposes a name, a description, inputs and outputs. They differ in what runs underneath.
| Action target | What runs | Typical use | Output character |
|---|---|---|---|
| Flow | A flow built in Flow Builder | Update a record, look up data, run a multi-step process | Deterministic. Same inputs give the same result. |
| Apex | An invocable Apex method | Logic or integrations that need code | Deterministic, as written in your code. |
| Prompt template | A prompt template run through Prompt Builder | Generate text from record data, such as a summary or a draft | Generated text that varies between runs. |
| Standard action | A prebuilt action from Salesforce | Common tasks such as querying records | Defined by the standard action. |
The most important row for this tutorial is the prompt template. The other types are for doing or fetching. A prompt template is for writing. When the task is "produce a piece of text from these records", a prompt template is a natural fit. When the task is "change this record" or "call this service", it is not.
Prompt template versus agent instructions
New builders often confuse these two, because both are natural language aimed at an LLM. They differ in several ways.
| Row | Topic instructions | Prompt template |
|---|---|---|
| Who reads it | The agent's reasoning engine, on every turn in that topic | A separate LLM call, made only when the action runs |
| Purpose | Decide behavior and sequence: when to ask, when to call which action | Produce one specific piece of text |
| Data | Whatever is in the conversation, plus action outputs | Merge fields that pull record data at run time |
| Reuse | Belongs to one topic | Can be used by several agents, and by Flow and Apex |
| Where it is built | Agent Builder | Prompt Builder |
A useful rule is that instructions say when and why. The template says what to write. If you put the full text-generation rules into topic instructions, the agent has to hold them in mind across every turn, and you cannot test them in isolation. If you move them into a template, you can preview the template with a real record before any agent is involved. A later chapter covers that preview.
Here is the pairing from this tutorial's running example. The first block is the template body. It is where the facts and output rules live.
You are a service assistant. Write a short, factual summary of the case below for a customer call hand-off.
Case number: {!$Input:Case.CaseNumber}
Subject: {!$Input:Case.Subject}
Status: {!$Input:Case.Status}
Description: {!$Input:Case.Description}
Rules:
- Use at most five sentences.
- Use only the information above. If something is missing, say it is unknown.
- Do not promise refunds or dates.The second block is topic text. It does not repeat the writing rules. It says when to call the action and what to do with the result.
Topic: Case Hand-off
Classification description: Handles requests to summarize a support case for a colleague or a customer call.
Scope: Summarizing existing cases only. Does not create or update cases.
Instruction 1: When the user asks for a case summary, ask for the case number if it was not given.
Instruction 2: Once the case is identified, use the Summarize Case action and return its output to the user without rewriting the facts.Notice the split. The topic text mentions the action by name and states a condition for calling it. It also states what to do with the output. The template text contains nothing about conversation flow.
What an action contract contains
Every action, whatever its target, presents the same contract to the agent:
- Name and description. The reasoning engine reads these to decide whether the action fits the request. A vague description leads to the wrong action or no call at all.
- Inputs. Named values the agent must supply. For a prompt template action, these correspond to the template's input resources, such as a Case record.
- Outputs. Values the action returns. For a prompt template action, the main output is the generated text.
A later chapter covers how to map inputs and outputs. For now, remember that the agent supplies inputs from the conversation. If your action needs a Case record and the user gave a case number, something has to turn that number into the record. Often the topic instructions tell the agent to ask for the number first, and a lookup step handles the rest.
Where actions can go wrong
These failure modes are common, and each one points to a different part of the structure.
- The agent never calls the action. Check that the action is attached to the selected topic, and that the instructions or the action description make the use case clear.
- The wrong topic is selected. The classification description and scope overlap with another topic, so the agent chooses the wrong set of actions.
- The agent rewrites the output. The output arrives correctly and the agent changes the facts. The topic instructions should say to return the output unchanged, as the example above does.
- The agent asks for the wrong input. The input names or descriptions are unclear, so the agent cannot map the user's words onto them.
- The text is wrong but the call is right. The action ran correctly, so the problem is in the template: its merge fields, its grounding data or its rules.
The last case is the most useful to learn early. It tells you which tool to open. Wrong calls are debugged in Agent Builder. Wrong text is debugged in Prompt Builder.
How this chapter connects to the rest
The remaining chapters follow the order in which you build. First you build the template: its type, its inputs and its grounding. Then you attach it to a topic as an action, write the instructions that call it, and map its inputs and outputs. Finally you test, version and activate it, and learn how Flow and Apex can call the same template. Keep the division from this chapter in mind throughout: the template writes, the action connects, and the topic decides.
Exercise
A user asks your agent for a case summary. The agent selects the right topic and calls the Summarize Case action with the correct case, but the summary contains a promised refund date that is not in the case data. Which tool do you open first to investigate, and what do you check?
Show answer
Open Prompt Builder first. The topic and the action call were correct, so the fault is in the generated text. Preview the template with that case and check its merge fields and grounding data, and check that its rules forbid promises and limit the output to the supplied information. Then, if the agent changed the output after the action returned it, check the topic instruction that says to return the output without rewriting the facts.
Exercise
Name two reasons you might choose a Flow action instead of a prompt template action, and one reason you might choose a prompt template.
Show answer
Choose a Flow when the task must change data or follow fixed steps, and when you need the same result every time for the same inputs. Choose a prompt template when the task is to generate text, such as a summary or a draft, from record data.