Agent Script Pattern: Topic Selector Strategies
The topic selector is the start_agent block that serves as the entry point for your agent.
The topic selector (also described as the start_agent topic in Agent Script) controls your agent's entry point and routing logic. Keep it focused on essential topics and use clear descriptions, filtering, and conditional transitions to guide users to the right place.
Every user utterance begins at the start_agent topic. It welcomes users, classifies intent, routes to appropriate topics, and controls which topics are available based on user state. A well-structured topic selector ensures that your users get to the right topic as effectively as possible.
Pattern Example: A customer service agent's topic selector forces unverified users through identity verification, then routes verified users to Order Management, Returns, or Escalation based on their intent.
The start_agent topic has the same structure as any other topic. However, it's usually geared towards effective and efficient topic routing.
Remove references to a topic if you want the topic to be accessible only via transitions from other topics.
Good descriptions help your agent select the best topic. Be specific about what each topic handles.
You can gate and control flow using available when filters. See the Filtering Pattern for examples.
For critical routing decisions, use conditional transitions in instructions instead of relying on the LLM to choose the right flow. See the Required Topic Workflow Pattern for examples.
For more on how to effectively transition to another topic, see the Transitions Pattern.
By default, the Topic Selector is defined as the starting topic in your agent's Agent Script. In other words, this is the topic that uses the start_agent prefix instead of the topic prefix.
However, you can define another topic as the starting topic instead (in Agent Script, the new topic becomes the start_agent topic). You can choose to use the Topic Selector to move to topic classification later in the conversation, or you can remove the Topic Selector from your agent altogether if you want to control topic routing differently.
- Limit topics: Start with essential topics and add more gradually as needed. Fewer topics means clearer routing decisions for your agent.
- Use the
go_to_prefix: Name transition actions with ago_to_prefix (for example,go_to_orders) so the agent understands they navigate to other topics. - Write detailed descriptions: Use detailed and unique descriptions so the agent knows when to choose a topic, especially if you have similar topics.
- Hide topics based on context: Use
available whento control topic visibility. - Conditional logic: Use conditional logic to guarantee that routing occurs before other processing.
- Help Page: Topic Classification and Routing
- Guide: An Agentforce Guide to Context Engineering
- Pattern: Filtering with Available When
- Pattern: Required Topic Flow
- Pattern: Transitions
- Reference: Start Agent Block
- Reference: Flow of Control