Appearance
Exercise 2: Extend Agents with Topics and Actions
In this exercise, you’ll create a new topic, wire it into the Topic Selector 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 topic
Next, use the Authoring Agent to create a new topic.
In Agentforce Builder, click the + sign besides Topics in the explorer.
Select Create new topic.
Set the following values:
Field Value Name Storefront SearchDescribe the job you want the topic to do 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:
txtAssist 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: Add the topic to the Topic Selector
Expand the Topic Selector folder in the explorer and open the topic.
Open the Authoring Agent by toggling the right panel.

Enter the following prompt into the Authoring Agent dialog.
txtAdd the new storefront search as transitions to the topic selector.Click Accept All.
Click Save to save the changes.
Step 3: Test topic routing
Click Preview to test the agent.
Enter the following prompt:
txtCan you search for a restaurant for me?Press Enter on your keyboard.
Click on the entry next to Transition to Topic in the Interaction Details section on the right, and explore the reasoning details.

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

Enter
Store Searchas action name and click Create and Open.
Enter the following information:
Field Value Description Retrieves store information based on a user query.Reference Action Type ApexReference Action Get Storefronts by NameOutputs - Storefronts Select checkbox Show in conversationClick Save.
Open the Storefront Search topic 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.
Update the Storefront Search Topic Agent Script
In the Storefront Search Topic, Switch the current view from Canvas to Script.
Click inside of the Script Editor and open the search (
CMD + Fon Mac orCTRL + Fon 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 5: Test the storefront action
Click Preview.
Enter the following prompt:
txtProvide me information about the fusion bites restaurantPress Enter on your keyboard.
Click on Action: Store Search in the Interaction Details area and review the action inputs and outputs.

Summary
You created a Storefront Search topic, added it to the Topic Selector so the agent can route correctly, and extended the topic with an Apex-based Store Search action to retrieve storefront details. You then tested both routing and action execution in Preview using Interaction Details.