Sub topic 11
Telling the agent when and how to use an action
This chapter assumes you know what a topic is, that actions are attached to topics, and that each action has labeled inputs and outputs. Here you will write the instructions that tell the agent when to call an action, what to give it, and what to do with the result.
Why actions need instructions
An action's name and description tell the agent that it exists. They do not say when to call it, what to ask the customer first, or how to react to each result. Without that guidance the agent guesses. Common outcomes are calling the action too early with a missing input, skipping it and answering from memory, or reading an error as a success.
Put this guidance in the topic instructions, next to the steps that use the action.
The four things to state
Good action instructions cover four points:
- Trigger. The condition that makes the agent call the action.
- Inputs. Where each input value comes from, and what to do if it is missing.
- Result handling. What each possible output means and what to say for it.
- Limits. What the agent must never do with the action or its data.
The order-status topic from earlier shows all four:
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 1 handles the input. Step 2 is the trigger and names the action exactly as it is labeled. Steps 3 and 4 handle results. Step 5 sets a limit.
Connecting instructions to the action definition
The agent matches instructions to actions by name and description, so keep them consistent.
- Use the action's label exactly. "Get Order Status" in the instructions must match the label in Builder. A paraphrase such as "the lookup tool" can leave the agent unsure which action you mean.
- Refer to inputs and outputs by their labels. In the Apex example, the input is "Order Number" and the output is "Status". Instructions that use those words line up with the variable descriptions.
- Reuse the exact output values your code returns. The Apex method returns the string
Not found, so step 3 checks for'Not found'. If the instruction said "no result" or "empty", the agent would have to guess.
Common errors
| Problem | Symptom in testing | Fix |
|---|---|---|
| No trigger condition | The agent answers from general knowledge instead of calling the action | Add a step that says when to use the action |
| Missing input rule | The action runs with a blank or invented value | Add a step to ask for the value first |
| Unhandled result | The agent says something odd for a failed lookup | Add a step for each result you expect, including errors |
| Vague action name | The agent picks the wrong action | Use the exact label |
| No limits | The agent offers actions outside the topic's scope | Add a "Never..." step |
Verify in Builder
After you write the steps, open the conversation preview in Builder and test each branch: a valid order number, an unknown one, and a request with no number. Check the reasoning details to confirm the agent called the action with the right input. If a branch fails, edit the step that covers it and test again.
Exercise
A topic has an action labeled "Create Case". The agent sometimes creates a case before the customer has described the problem. Write one instruction step that fixes this, and say which of the four points (trigger, inputs, result handling, limits) it addresses.
Show answer
For example: "Ask the customer to describe the problem in one or two sentences. Only after they have done so, use the Create Case action with that description." This addresses inputs, because it says where the input comes from and what to do while it is missing. It also sharpens the trigger by tying the call to a condition.