Sub topic 11
Action instructions and input settings
This chapter assumes you can build an autolaunched flow with input and output variables, you know where to find Agent Builder in Setup, and you have already written variable descriptions (the previous chapters covered these). Here you register the flow as an action and tell the agent when to call it and how to handle each value.
Where instructions fit
When you add a flow to a topic, Agent Builder creates an action from it. The agent's language model sees these pieces of text for every action in the active topic:
- The action name.
- The action instructions.
- Each input's name and description.
- Each output's name and description.
The model reads this text to choose an action and to decide what to put in each input. It does not read your flow's elements. Anything the flow does that you want the agent to know about must appear in this text.
Settings are different from text. Per-input and per-output settings change how the agent runtime treats a value. For example, a setting can make an input required, or stop the agent from asking the user for it.
Writing action instructions
Action instructions answer one question: when should the agent call this action? Write them for a model that has never seen your org.
A useful instruction has three parts:
- The trigger: what the customer is asking for.
- The precondition: what the agent must already have.
- Any exclusion: a nearby situation where this action is the wrong one.
Compare these two versions for the same flow.
| Weak | Better |
|---|---|
| Gets case info. | Use this action when the customer asks about the status of an existing case and has given a case number. Do not use it to create or update a case. |
The weak version does not say which requests count, so the model may call the action for "open a new case" or skip it for "where is my ticket?". The better version names the request type, the required value, and the boundary with a neighboring action.
Some rules that hold up in practice:
- Describe the situation, not the implementation. "Queries the Case object with a SOQL filter" tells the model nothing about when to call it.
- Use the words customers use. If users say "ticket" and your object is Case, mention both.
- Keep one action to one job. If the instructions need the word "or" to cover two different purposes, split the flow (see the earlier chapter on focused actions).
- Put rules about the whole conversation in the topic instructions. Put rules about this call in the action instructions.
Input settings
Each flow input variable appears in the action with its own settings. The label wording varies slightly between releases, so check your org's Agent Builder. The settings you will meet are:
| Setting | What it does | Use it when |
|---|---|---|
| Require input | The agent must have a value before it runs the action. If the value is missing, it asks the user. | The flow cannot do anything useful without the value. |
| Collect data from user | The agent gets the value by asking the user. | The value only the customer knows, such as a case number. |
| Instructions (per input) | Text that tells the agent how to get or format the value. | The format matters or the source is not obvious. |
When "Collect data from user" is off, the agent is expected to fill the input from context it already has, such as earlier conversation turns or the output of another action. Use this for values like a Contact Id that a previous action returned. If nothing in context can supply the value, the call has no source for it, so check that the input's source is real.
Do not mark an input as required just because the flow variable is not nullable in your head. If your flow handles a blank value, for example by returning a message, an optional input can be fine. If the flow would fail or return wrong data on a blank, make the input required.
Output settings
Outputs have settings too. The common ones control whether the agent shows the value in the conversation and whether the value is hidden from the agent's reasoning altogether (a "filter" option). Hiding is useful for internal Ids or technical fields that would only confuse the model or leak into replies. Outputs the agent should speak about need a clear description, which is the same skill as for inputs.
A worked example
Start with the variables in the flow. These two are the only ones marked for input and output, and each has a description.
<variables>
<name>caseNumber</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>false</isOutput>
<description>The Case Number of the case to look up, for example 00001026.</description>
</variables>
<variables>
<name>caseStatus</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>false</isInput>
<isOutput>true</isOutput>
<description>The current Status of the case, or a short message if no case was found.</description>
</variables>The isInput and isOutput flags are what make a variable appear as an action input or output at all. Without them, Agent Builder will not list the variable.
Now the values you enter when you register the flow as an action:
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.Walk through what happens when a customer writes, "Can you check on my ticket?"
- The model matches "check on my ticket" to the action instructions, since a status request is the stated trigger.
- The precondition says a case number is needed. None was given, so the agent asks for it. This follows from "Ask for it if it was not provided" together with the required input.
- The customer replies "00001026". The agent places it in
caseNumber. - The flow runs and returns
caseStatus. - The agent replies using the output instruction, in plain language, rather than pasting the raw value.
In step 2, the instruction and the setting work together. The text tells the model what to say, and the required setting makes sure the flow does not run with an empty value.
Instructions that guide the output
The output instruction is easy to skip, and the agent will then repeat whatever string comes back. If the flow returns "Escalated", the agent may say exactly that. Compare:
- Without guidance: "Status: Escalated."
- With "Tell the customer the status in plain language": "Your case has been escalated to a specialist who will follow up with you."
The model still decides the exact words, so do not expect the same sentence every time. If you need exact wording, such as for legal text, build the sentence inside the flow and return it as the output.
Common errors
- The action is never called. The instructions are vague, or they overlap with another action in the topic. Make the trigger specific and add an exclusion. Also confirm the action is in the topic the agent selected.
- The action is called too often. The trigger is too broad, for example "Use this for anything about cases".
- The agent invents a value. The input is optional and not collected from the user, so the model guesses. Make it required, or collect it from the user.
- The agent asks for a value the customer already gave. The input description is missing a format hint or an example, so the model cannot match the earlier text to it. Add an example such as "for example 00001026".
- The agent asks for internal data. An input meant to be filled from context, such as a record Id, is set to collect from the user. Turn that setting off and make sure another action provides the value.
- Edits do not seem to apply. After you change the flow's variables, you may need to re-add or refresh the action so Agent Builder reads the new inputs and outputs. Activate the flow version first.
Checklist before you move on
- The instruction names the trigger, the precondition, and one exclusion.
- Every required input has a description with an example.
- Inputs filled from context are not set to collect from the user.
- Outputs shown to customers have a plain-language instruction. Internal outputs are hidden.
- Rules that must always hold are enforced in the flow, not only in text.
Exercise
A flow takes an input named contactId and another named newPhone, and updates the phone number on a Contact. An earlier action in the topic, Find Contact, already returns the contact's Id. How should you configure contactId and newPhone in the update action, and what is one sentence you would put in the action instructions?
Show answer
Make both inputs required. Set newPhone to be collected from the user, since only the customer knows the new number. Turn off "Collect data from user" for contactId so the agent fills it from the Find Contact output instead of asking the customer for an Id. Example instruction: "Use this action when the customer asks to change the phone number on their contact record and the contact has already been identified. Do not use it to change any other field."