Sub topic 4
How a Request Is Matched to a Topic
This chapter assumes you know basic Salesforce concepts, have seen Flow or Apex at a high level, and have a general idea of what a large language model (LLM) does. You should also know that an agent is built from topics, instructions, and actions.
What topic classification does
A topic is an area of responsibility for an agent. When a user sends a message, the agent has to decide which topic, if any, the message belongs to. This step is called topic classification. It runs before any action is chosen, because the actions available to the agent depend on the topic it picks.
The reasoning engine does the classification. It sends the user's message, the recent conversation, and the list of topics to the LLM. The LLM compares the message with each topic's name and classification description, then picks the best fit.
What the engine reads
Classification relies on text you write. The engine does not look at a topic's actions or detailed instructions at this stage. It reads the topic's name and classification description.
| Topic field | Used for classification? | Purpose |
|---|---|---|
| Name | Yes | Short label for the topic |
| Classification description | Yes | Says what kinds of requests belong here |
| Scope | After a topic is chosen | Sets what the agent will and will not do |
| Instructions | After a topic is chosen | Guide the agent's behavior and action choice |
| Actions | After a topic is chosen | Define what the agent can run |
Treat the table as a working model. The exact prompt that Salesforce builds can change between releases, so test your agent instead of assuming.
A worked example
Take the Order Support topic from the spine:
Topic: Order Support
Classification description: Handles customer questions about the status of an existing order, such as where it is or when it will arrive.
Scope: Look up order status and explain it. Does not process returns, refunds, or changes to an order.Suppose the agent also has a topic named Returns and Refunds. Consider three messages:
- "Where is my order 10452?" matches Order Support. The description mentions where an order is.
- "I want my money back for order 10452." matches Returns and Refunds, because Order Support says it does not process refunds.
- "What's the weather today?" matches neither topic. The agent should fall back to a default response, such as a general topic that politely declines.
Conversation context matters
The engine classifies with the conversation history, not only the latest message. A reply such as "It's 10452" has no meaning alone. After the agent asked for an order number, the history shows it belongs to Order Support. The agent can also change topics partway through a conversation when the user changes subject.
Common errors
- Overlapping descriptions. If two topics both claim "questions about orders," the LLM may pick either one. Give each description a distinct boundary.
- Vague descriptions. "Handles customer stuff" matches almost anything. Name the kinds of requests and give examples.
- Writing routing rules in instructions. Instructions are not read during classification, so a line such as "use this topic for refunds" belongs in the classification description.
- Too many topics. Each extra topic is another choice that can be confused with its neighbors. Merge topics that differ only slightly.
- No fallback. Without a topic for off-topic requests, the agent may force a poor match.
Checking the result
The Agentforce testing tools show which topic the agent chose for a given message. Use them to confirm that a borderline request lands where you expect. A later chapter covers tracing in detail.
Exercise
A customer writes, "Can I change the address on order 10452?" Your Order Support topic says it does not handle changes to an order. Which part of your configuration decides whether this message goes to Order Support, and what would you edit if it went there by mistake?
Show answer
The classification description (with the topic name) decides the topic. If the message was wrongly routed to Order Support, edit that description to state clearly that order changes are excluded. Make sure another topic, such as Order Changes, has a description that claims address changes. Then retest the message.