Sub topic 12
Combining several actions in one conversation
This chapter covers how an agent runs more than one action to finish a request, how data passes between actions, and how to write topic instructions that keep the sequence reliable. It assumes you have read the earlier chapters on topics, action inputs and outputs, and the record lookup, summary, change, and email actions. You should know what an Account record is and what a topic's instructions do.
Why requests need more than one action
Most real requests are not a single step. Consider this message: "Summarize the Acme account and email the summary to the primary contact." No single standard action does all of that. The agent has to:
- Find the Acme account record.
- Summarize that record.
- Find the primary contact.
- Draft an email that uses the summary.
Each step is one action. The agent's reasoning loop picks the next action after each result comes back. You do not write the sequence as code. You shape it through three things: the actions you put in the topic, the instructions you write, and the inputs and outputs you configure on each action.
How the reasoning loop chains actions
For each user message, the agent repeats a loop:
- Pick the topic that matches the request.
- Read that topic's instructions and its list of actions.
- Decide on the next action and fill its inputs.
- Run the action and read the output.
- Decide whether the request is done, whether another action is needed, or whether to ask the user something.
The agent only sees actions in the currently selected topic. A chain that needs actions from two topics will not work as one chain unless the topics are redesigned. Keep every action a workflow needs in the same topic.
How data passes between actions
An action does not call another action directly. The agent carries data between them. The output of one action becomes available to the agent, and the agent supplies it as an input to the next action.
The most common handoff is the record ID. Actions such as Get Record Details, Summarize Record, and Update Record operate on a specific record, so they need its ID. Identify Record by Name or Query Records produces that ID. A typical lookup-then-act chain looks like this:
| Step | Action | Input | Output used later |
|---|---|---|---|
| 1 | Identify Record by Name | Object and name from the user | Record ID |
| 2 | Summarize Record | Record ID from step 1 | Summary text |
| 3 | Draft or Revise Email | Summary text and recipient | Draft email |
Three settings in Agentforce Builder control how well this handoff works:
- Input source. For each input, you choose whether the agent should ask the user for it or take it from earlier data in the conversation. An ID input should come from a previous output, not from the user. Users do not know record IDs.
- Input and output descriptions. The agent decides which output matches which input mainly by reading descriptions. "Record ID of the account found in the previous step" is much better than "ID".
- Output visibility. Intermediate outputs, such as a raw record ID, do not need to be shown to the user. Where Builder lets you hide an output from the conversation, hide the ones that only exist to feed the next step. The exact option labels can differ between Builder releases.
Writing instructions that produce a chain
The model chooses the order, but your instructions strongly influence it. Good chaining instructions state dependencies, not just goals. Here is an example for a topic that supports the scenario above.
Topic: Account Follow-Up
Classification description:
Help a user review an account and send follow-up communication to a contact on that account.
Instructions:
1. When the user names an account, first run Identify Record by Name for the Account object. Use the returned record ID for every later step.
2. If Identify Record by Name returns no match or more than one match, ask the user to clarify. Do not continue.
3. When the user asks for an overview, run Summarize Record with the account's record ID.
4. When the user asks to email a contact, run Query Records to find the contact on that account, then run Draft or Revise Email. Use the summary as context if one was already produced in this conversation.
5. Show the draft to the user and wait for approval. Never send an email that the user has not reviewed.
6. Before running Update Record, restate the field and new value and ask the user to confirm.This works because of several habits:
- Each instruction names the action and says what it depends on ("use the returned record ID").
- Failure cases are handled explicitly (no match, several matches).
- The instruction says when to stop and ask, so the agent does not fill gaps with guesses.
- Steps are tied to user intent ("when the user asks for an overview"), so the agent does not run every action every time.
Avoid instructions that fix a rigid order for everything, such as "always run actions 1 to 5". Users often want only one step, and a forced chain wastes calls and can change data the user never asked about.
Chains that read, then write
Mixing read actions and change actions is where mistakes cost the most. A read chain that goes wrong gives a wrong answer. A write chain that goes wrong changes data. Follow these rules:
- Put the lookup first and the change last, so the change runs against a record you have already confirmed.
- Require confirmation before Create Record and Update Record in the instructions, as in step 6 above.
- Do not chain a change action to the output of a fuzzy lookup without a disambiguation step. If the name "Acme" matches three accounts, picking one silently is a data quality problem.
- Remember that each action runs as the user. A chain can stop partway if the user lacks access to a record or field. This is correct behavior, and your instructions should tell the agent to report it rather than try another route.
Common failure modes
| Symptom | Likely cause | Fix |
|---|---|---|
| The agent asks the user for a record ID | The input is set to collect from the user, or its description is vague | Set the input to use the earlier output and describe it as "ID from the previous lookup" |
| The agent summarizes the wrong record | The lookup matched several records and the agent chose one | Add an instruction to ask for clarification when there is not exactly one match |
| The chain stops after the first action | The instructions do not say what comes next, or the next action is not in the topic | Add the missing action to the topic and state the dependency in the instructions |
| The agent skips the lookup and invents a value | Instructions allow answering from memory | State that the lookup must run before any later action |
| An action returns nothing for one user but works for another | Permissions differ between the two users | Check object and field access for the user in the conversation |
Checking a chain in testing
Use the Builder's conversation preview and its plan or trace view to see which actions ran, in what order, and what inputs and outputs they had. For a chain, check three things in the trace:
- Each later action received the value that an earlier action produced.
- No action ran that the request did not need.
- The agent stopped and asked when a lookup was ambiguous.
Test at least one failing case, such as an account name that does not exist, in addition to the happy path.
Exercise
A user says, "Change the rating on Globex to Hot." Using standard actions, name the actions the agent should run in order. State where the topic instructions should force a pause, and what the agent should do if the lookup returns two Globex accounts.
Show answer
First run Identify Record by Name for the Account object with the name "Globex" to get the record ID. Then run Update Record with that ID, the Rating field, and the value Hot. The instructions should force a pause before Update Record: the agent restates the field and new value and waits for the user's confirmation. If the lookup returns two Globex accounts, the agent should not run Update Record. It should ask the user which account they mean, then continue with the chosen record's ID.
Exercise
The agent keeps asking users to type a record ID before running Summarize Record. Give two changes in Agentforce Builder or the topic instructions that fix this.
Show answer
Configure the record ID input on Summarize Record so it takes its value from the earlier lookup output instead of asking the user, and give it a clear description such as "ID of the record found by the previous lookup". Also add an instruction that tells the agent to run Identify Record by Name first and use the returned ID for all later steps.