Sub topic 8
Defining topics and writing instructions
This chapter assumes you have created an agent in Agentforce Builder and can open it in the editor. It also assumes you know what an action is. You don't need Apex yet.
What a topic is
A topic is a category of work the agent can handle. Each topic bundles three things: a description that tells the agent when the topic applies, instructions that say how to behave inside it, and the actions it may call.
When a user sends a message, the agent first picks the topic that best matches the request. It then follows only that topic's instructions and uses only that topic's actions. A topic therefore works as a boundary as well as a label.
The parts of a topic
| Part | Purpose | Common mistake |
|---|---|---|
| Name | Label for you and the builder | Vague names such as "General" |
| Classification description | Helps the agent decide whether the topic fits a request | Overlapping with another topic |
| Scope | States what the topic does and does not cover | Leaving out the "does not" side |
| Instructions | Rules the agent follows once the topic is chosen | One long paragraph of mixed rules |
The exact field labels can differ between releases, so check what your builder shows. The ideas stay the same.
Writing a good topic
Start with one job per topic. If you can't describe the job in a single sentence, split the topic. Two topics with similar descriptions make the agent's choice unreliable, so keep their descriptions clearly different.
Write instructions as short, numbered steps in the order the agent should act. Each step should be one rule that you can test. Say what to do when something goes wrong, such as an empty result. Say what to do for out-of-scope requests as well.
Here is a sample topic for the case-count action you will build later:
Topic: Case Status Questions
Description: Answer questions about the status of a customer's support cases.
Instructions:
1. Ask for the account if the user has not named one.
2. Use the Get Open Case Count action to look up the number of open cases.
3. Report the number in one sentence. Do not guess when the action returns no result.
4. If the user asks about anything other than case status, say you cannot help with that.Each line has a job:
- Step 1 handles missing input before any action runs.
- Step 2 names the action, so the agent knows which tool to use.
- Step 3 fixes the reply format and forbids guessing.
- Step 4 sets the boundary.
Common errors
- Vague instructions. "Be helpful with cases" gives the agent nothing to follow. Use concrete steps.
- Too many topics. Each extra topic gives the agent more ways to choose wrongly. Start with one or two.
- Overlapping descriptions. If "Case Status" and "Case Help" both match a message, the agent may pick either one.
- Instructions that need data the agent can't reach. An instruction such as "check the customer's tier" fails unless an action returns that data.
- Contradictory rules. "Always answer briefly" and "explain every field" will conflict.
Exercise
Exercise
A topic called "Account Help" has the description "Help with accounts." Another topic called "Account Updates" has the description "Help with changes to accounts." Users report that the agent sometimes picks the wrong one. What are two changes that would reduce the confusion?
Show answer
Make the descriptions clearly distinct (for example, one for reading account information and one for editing account fields), and state in each topic's scope what it does not cover. Merging the two into one topic with separate numbered instructions is also a valid fix.