Sub topic 2
Setting a Topic's Scope
Assume you know Salesforce objects, fields, and records, and you understand the basic role of a large language model. This chapter focuses on how scope, instructions, and action choices control an Agentforce agent.
Setting a Topic's Scope
A topic groups requests that need the same kind of work. Its scope defines what the topic may handle and where it must stop. A clear scope prevents overlap with other topics.
For example, an Order Status topic can look up an existing order and report its status. It should not process returns, issue refunds, or create new orders. State both the allowed work and the excluded work.
Topic Instructions: Guiding the Agent's Reasoning
Instructions tell the agent how to work inside the topic. Write them as ordered steps with conditions and expected results:
- Ask for the order number if it is missing.
- Use the status action with that number.
- If no record is found, ask the customer to check the number.
- Otherwise, state the current status.
- Do not reveal another customer's order details.
These instructions connect the user's request to the topic's actions.
Writing Instructions That Are Specific and Testable
An instruction is testable when you can observe whether the agent followed it. Replace “help with orders” with “use Get Order Status after receiving an order number.” Include required inputs, decision points, limits, and the response format. Avoid vague goals such as “be helpful” unless you also define the behavior that demonstrates them.
Actions: What the Agent Can Do
An action is an operation the agent can invoke. It may query data, update a record, calculate a result, or generate text. The action description should state its purpose and the information it needs.
Choosing an Action Type
| Action type | Best fit |
|---|---|
| Flow | Guided Salesforce automation and standard data operations |
| Apex | Custom logic, complex queries, or integrations |
| Prompt template | Controlled text generation from supplied context |
| Standard action | Common Salesforce capability already provided |
Choose Flow for maintainable declarative work. Choose Apex when code provides necessary control, but enforce sharing and user permissions. Use prompt templates for language tasks, not for enforcing business rules. Prefer standard actions when they already meet the requirement.
Exercise
An agent should look up an order and return “Not found” when no record matches. Which action type is usually appropriate for custom query logic?
Show answer
Use Apex when the lookup needs custom query logic. Use Flow instead when a declarative record lookup fully meets the requirement.