Sub topic 7
Writing Instructions That Are Specific and Testable
This chapter assumes you know what a topic is, how its classification description and scope work, and what an action is. You should also be able to open a topic in Agentforce Builder. Here you learn how to write the instruction list so you can check each line against a test conversation.
Why instructions need to be testable
The agent reads topic instructions every time it handles a request in that topic. Vague wording gives the model room to guess, and different guesses produce different answers on different days. A testable instruction states a condition and a result, so you can write a test message and see whether the agent complied.
Compare two versions of the same rule:
| Vague | Testable |
|---|---|
| Be helpful with order questions. | Ask for the order number if the customer has not given one. |
| Handle errors well. | If the action returns "Not found", say you could not find the order and ask the customer to check the number. |
| Protect customer privacy. | Never share details about orders that belong to other customers. |
Each testable line suggests a test. Send a message with no order number and see if the agent asks for one. Make the action return "Not found" and read the reply.
Four habits for writing instructions
- One step per line. Each line should hold one decision or one action. A line with three "and" clauses is hard to test, because a failure could come from any clause.
- Order the steps. Number the list in the sequence the agent should follow. Put the check for missing information before the action call.
- Name the action. Write "Use the Get Order Status action", using the exact action label. The agent can then match the line to the action.
- Cover the failure path. Say what happens when an action returns nothing, returns an error value, or when the customer asks for something outside the scope.
Here is a complete instruction set that follows all four habits:
1. Ask the customer for their order number if they have not given one.
2. Use the Get Order Status action with that order number.
3. If the action returns 'Not found', tell the customer you could not find the order and ask them to check the number.
4. Otherwise, state the status in one sentence.
5. Never share details about orders that belong to other customers.Step 4 sets a length ("one sentence"), which you can measure. Step 5 is a prohibition, which you test by asking about someone else's order.
Common mistakes
- Duplicating the scope. If the scope says the agent cannot cancel orders, do not rewrite that in the instructions. Add an instruction only for what the agent should do when asked, such as "If the customer asks to cancel, tell them you cannot cancel orders."
- Contradicting yourself. "Always answer briefly" and "Explain each status in detail" cannot both hold. Read the list top to bottom for conflicts.
- Using absolute words loosely. Use "never" and "always" only for rules you really mean.
- Describing tone only. "Be friendly" cannot be tested. "Greet the customer by first name" can.
From instruction to test
The flow below shows how one instruction becomes a check in Builder.
Change one instruction at a time between runs. If you change three lines and the behavior improves, you will not know which change helped.
Exercise
Rewrite this instruction so it is specific and testable: "Deal with missing information properly." The topic looks up order status and needs an order number. Then describe one test message for it.
Show answer
Example rewrite: "If the customer has not given an order number, ask for it before using the Get Order Status action." Test message: "Where is my order?" with no number. A pass means the agent asks for the order number and does not call the action.
Exercise
A topic's instruction list has the line "Check the order, tell the customer the status, and offer a refund if it is late." Give two reasons this line is hard to test and one fix.
Show answer
It holds three steps, so a failure cannot be traced to one of them. A refund is likely outside this topic's scope, so the line conflicts with it. Fix: split the line into separate numbered steps, keep only the status lookup and reply, and remove the refund offer or replace it with "If the customer asks for a refund, tell them you cannot process refunds here."