Sub topic 11
Action Instructions and Input Settings
This chapter assumes you can build an autolaunched flow, you know how to mark variables as available for input and output, and you have already added a flow to a topic in Agent Builder. Here you will configure how the agent decides to call the action and how it fills in each input.
Why instructions matter
When a user sends a message, the agent's language model picks a topic and then chooses among that topic's actions. It does not read your flow. It reads the action name, the action instructions, and the descriptions you gave to the inputs and outputs. If these are vague, the agent may call the action at the wrong time, skip it, or guess at input values.
Two kinds of settings control this behavior:
- Action instructions describe when to use the action and what it does.
- Input and output settings describe how each value is collected or reported.
Writing action instructions
Action instructions answer one question: under what conditions should the agent call this action? State the trigger and the precondition together.
A weak instruction:
Gets case information.A stronger instruction:
Use this action when the customer asks about the status of an existing case and has given a case number.The stronger version names the user intent (asking about status), the object (an existing case), and the precondition (a case number was given). That precondition helps the agent avoid calling the action with an empty input.
Keep these habits:
- Start with "Use this action when".
- Name the user intent in the customer's words, not your object names.
- State required preconditions.
- Say what the action does not do if a nearby action could be confused with it.
Input settings
Each input of the action has its own settings. The sketch below shows the values for the case lookup action used in this tutorial.
Action name: Get Case Status
Flow: Get_Case_Status (autolaunched flow)
Action instructions: Use this action when the customer asks about the status of an existing case and has given a case number.
Input caseNumber: Collect from the user. Ask for it if it was not provided.
Output caseStatus: Tell the customer the status in plain language.The input line tells the agent to collect the value from the user. It also says what to do when the value is missing: ask. Without that, the agent may invent a case number.
Not every input should come from the user. Some values are better taken from the conversation context, or fixed by the design. Choose the source for each input on purpose:
| Input source | Use it when | Example |
|---|---|---|
| Collect from the user | Only the customer knows the value | Case number |
| Taken from context | The value is already known in the session | The signed-in contact's ID |
| Fixed by the design | The value should never vary | A record type or a channel name |
Take care with values the agent should not guess. A record ID the user cannot know should come from context or from a previous action's output, not from the user.
How the pieces connect
The flow's variable descriptions, written earlier, feed into these settings. The description tells the model what a value means. The input setting tells it where the value comes from.
The diagram below shows the order of decisions the agent makes on one request.
Common errors
- Instructions describe the flow, not the intent. "Runs the Get Case flow" tells the model nothing about when to use it.
- Overlapping actions. Two actions with similar instructions cause inconsistent choices. Narrow each one, or add a "do not use for" sentence.
- No missing-value rule. If the input setting does not say to ask, the agent may fabricate a value.
- Technical output. If the output setting does not ask for plain language, the agent may repeat raw values such as API names.
Exercise
A customer says, "Where is my refund?" Your Get Case Status action has the instruction "Gets case information." Rewrite the instruction so the agent calls it only when the customer asks about an existing case and has provided a case number. Then write the input setting for caseNumber so the agent does not invent a value.
Show answer
Instruction: "Use this action when the customer asks about the status of an existing case and has given a case number." Input setting for caseNumber: "Collect from the user. Ask for it if it was not provided." The instruction names the intent and the precondition, and the input setting tells the agent to ask instead of guess.