Agentforce practice exercises: build and test an agent
Build an agent for the estate agency step by step: plan it, give it actions built with Flow and Apex, ground a prompt template in record data, and test it. You need a Developer Edition org with Agentforce turned on.
All exercises use the data model from our real estate practice project: Property__c, Buyer__c, Agent__c, Property_Agent__c and Property_Offer__c. Build Task 1 of that project first (about an hour), in a free Developer Edition org. Each exercise has a level, a check so you know it works, and a model answer to open after you have tried.
Exercises
1. Plan the agent on paper
BeginnerWrite a one-page plan for a "Property Assistant" agent for estate agents: who uses it, three jobs it does, the data each job needs, what it must never do, and when it hands over to a person.
- Each job maps to one subagent, and each subagent has the actions it needs.
Show a model answer
A good plan names, for example, three subagents (Property lookup, Offer guidance, Viewing booking), the actions for each (a flow to get property details, an Apex action to estimate commission, a flow to create a viewing task), guardrails ("never disclose seller legal notes", "never change offer amounts"), and when to hand over ("buyer complaints go to the branch manager").
2. A flow action: get property details
BeginnerBuild an autolaunched flow that takes a property name or ID and returns its price, type, city, status and virtual tour link. Add it to a subagent as an action.
- In the conversation preview, ask "What is the price of PROP-0007?" and see the action run.
Show a model answer
Give the flow input and output variables clear names and descriptions, for example "propertyRef: the property's ID or Property ID like PROP-0007". The agent reads those descriptions to fill inputs. Return text fields rather than a whole record when you only need a few values.
3. An Apex action
IntermediateAdd the Estimate Commission invocable method from the Apex exercises as an action, and write the subagent instructions so the agent only uses it for agents, not buyers.
- "What commission would I earn on a 400,000 offer?" calls the action and answers with a number.
Show a model answer
The invocable method's label and description, and each @InvocableVariable description, become the action's instructions. Mark the output as shown to the user. Restrict the subagent with an instruction and, more reliably, by giving the action only to the agent used by internal staff.
4. Ground a prompt template
IntermediateCreate a Field Generation prompt template that writes a 100-word listing description from the property's type, city, square feet, features and price. Attach it to the Description field.
- On a property record, the field's AI button drafts a description that uses the record's real values.
Show a model answer
In Prompt Builder, insert merge fields from the Property object into the template, and tell the model the tone, the length and what not to invent ("only use the details provided"). Preview with two or three different records before activating.
5. Write instructions that work
IntermediateFor each subagent, write a classification description and three to five instructions. Then test ten questions, including two that are off-topic and one that asks for seller legal notes.
- Each question goes to the right subagent.
- Off-topic questions are declined, and the legal notes are never shown.
Show a model answer
Topic descriptions decide routing, so make them specific and different from each other. Instructions should be short and testable ("Always ask for the property ID if it is missing"). Security does not rely on instructions: the agent's user must not have access to the legal notes field at all.
6. Test at scale
AdvancedCreate a test set of at least 20 utterances with the expected subagent and action for each, and run it in Agentforce's testing tools (Testing Center). Fix the failures and run it again.
- Your pass rate improves after you change descriptions and instructions.
Show a model answer
Keep the test set in a CSV so you can rerun it after every change. Most failures come from overlapping subagent descriptions or vague action descriptions, not from the model.
Keep going
Common questions
01Can I practise Agentforce for free?
Can I practise Agentforce for free?
Yes. Salesforce offers Developer Edition orgs with Agentforce and Data 360 features turned on, with usage limits. Trailhead also has hands-on playgrounds for many Agentforce modules.
02Do I need Apex for Agentforce?
Do I need Apex for Agentforce?
No. Many actions can be flows or prompt templates. Apex helps when you need complex logic or callouts, and developers are often asked to build invocable actions.