Appearance
Exercise 2 - Extend Agents with Subagents and Actions
In this exercise, you’ll create a new subagent, wire it into the Agent Router for routing, and add an Apex-based action so your agent can search for storefronts by name. You’ll validate routing and action behavior using Preview and Interaction Details.
Step 1: Create the Storefront Search subagent
- In Agentforce Builder, click the + sign besides Subagents in the explorer.
- Select + New Subagent.

- Set the following values:
| Field | Value |
|---|---|
| Subagent Name | Storefront Search |
| Description | Help users locate storefronts or restaurants by name and confirm the correct storefront based on user input. |
- Click Create and Open.
- Paste the following into the Instructions Section:
Assist the user in locating a storefront or restaurant by its name. Ensure the process is user-friendly and prioritizes accuracy.- Click Save to save the changes.
Step 2: Test subagent routing
- Click Preview to test the agent.
- Enter the following prompt:
Can you search for a restaurant for me?- Press Enter on your keyboard.
- Click on the entry next to Transition to Subagent in the Interaction Details section on the right, and explore the reasoning details.

Step 3: Create an Apex-based action (storefront search)
Next, you’ll create a subagent with an Apex-based action so the agent can search storefront records by name.
- In the Explorer, Select the Storefront Search Subagent
- Click on the plus icon besides Actions, and select New action.

- Set the following values:
| Field | Value |
|---|---|
| Action Name | Store Search |
| Description | Retrieves store information based on a user query. |
| Reference Action Type | Apex |
| Reference Action Category | Default (Invocable Method) |
| Reference Action | Get Storefronts by Name |
| Outputs - Storefronts | Select checkbox Show in conversation |
Click Create and Open.
Click Save.
Scroll down to Outputs and check the box for Show in conversation.
Open the Storefront Search subagent again from the the explorer view.
Under Actions Available For Reasoning, expand the store Store Search action.
TIP
Per default the action inputs are defined in a way that the LLM selects which value it should pass to the action.
Click Save.
In the Storefront Search Subagent, Switch the current view from Canvas to Script.
Click inside of the Script Editor and open the search (CMD + F on Mac or CTRL + F on PC).
Search for the
Store_Searchaction.
Find the storefronts output and make the following changes:
- Update the output type to
list[object] - update the
complex_data_type_nameto"@apexClassType/c__AgentStorefrontActions$StorefrontSummary"

- Update the output type to
Click Save.
Step 4: Test the storefront action
- Click Preview.
- Locate Set Context and click the little refresh icon to the right of it.

- Enter the following prompt:
Provide me information about the fusion bites restaurant- Press Enter on your keyboard.
- Click on Action: Store Search in the Interaction Details area and review the action inputs and outputs.

You created a Storefront Search subagent and extended it with an Apex-based Store Search action to retrieve storefront details. You then tested routing and action execution in Preview using Interaction Details.
Step 5: Create the Get Customer Profile action
- In Agentforce Builder, switch to the Canvas View.
- Click the + sign besides Subagents in the explorer.
- Select + New Subagent.
- Set the following values:
| Field | Value |
|---|---|
| Name | Order Issues & Refunds |
| Describe the job you want the subagent to do | This subagent resolves problems with orders, such as missing items, incorrect items, cold food, late deliveries, or orders that never arrived. It also handles support cases related to those issues—including creating a case, checking whether a case already exists, and providing case status/follow-up. It determines refund eligibility, issues refunds or credits, and explains outcomes clearly and empathetically to customers. |
- Click Create and Open.
- Paste the following into the Instructions Section:
Address the user's concerns regarding their order. If the user reports an issue with their order, determine the nature of the issue (e.g., missing items, incorrect items, cold food, late delivery, or non-delivery).- Click Save to save the changes.
Step 6: Create an action (Get Customer Profile)
- Open the Order Issues & Refunds folder in the explorer and select the subagent.
- Click on the + sign besides Actions, and select + New Action.
- Set the following values:
| Field | Value |
|---|---|
| Name | Get Customer Profile |
| Description | Retrieves a customer profile based on their email address. |
| Reference Action Type | Apex |
| Reference Action | Get Customer Profile |
| Reference Action Category | Leave as Default (Invocable Method) |
Click Create and Open.
Leave the default input and output settings.
Click Save.
Step 7: Create the related cases action
- Inside the Order Issues subagent, click on the + sign besides Actions, and select Create new action.
- Set the following values:
| Field | Value |
|---|---|
| Name | Get Related Cases |
| Description | Retrieves a customer’s related cases (basic details) based on the requested case status. |
| Reference Action Type | Apex |
| Refereance Action Category | Leave as Default (Invocable Method) |
| Reference Action | Get Related Cases |
Click Create and Open.
Click Save.
Scroll down to Outputs and enter the following information:
Field Value Outputs - Cases Select checkbox Show in conversation Click Save.
In the Get Related Cases Action, Switch the current view from Canvas to Script.
Find the Get_Related_Cases action.
Find the cases output and make the following changes:
- Update the output type to
list[object](Line 261) - update the complex_data_type_name to
"@apexClassType/c__AgentCaseActions$CaseSummary"(Line 264)
- Update the output type to
Click Save.
Step 6: Test the agent
- Click Preview.
- Locate Set Context and click the little refresh icon to the right of it.
- Enter the following prompt:
Can you show me all of my cases?- Press Enter on your keyboard.
- When the agent asks for an email address, enter:
alex.morgan@example.com- Press Enter on your keyboard.
- In Interaction Details, confirm the agent runs Get Customer Profile and then Get Related Cases, and that it shows the case results in the conversation.
You have created the core actions your agent will use for customer support workflows, added them to Order Issues & Refunds with baseline instructions, and tested that the agent can retrieve and display open cases.
This completes Exercise 2.
