Sub topic 4
Inputs, outputs, and how the agent fills them
This chapter assumes you know what an action is and how topics scope an agent's work. You should also know basic Salesforce objects, fields, and records. Here you will see how an action receives data, how it returns data, and how the agent decides what to put in each input.
Inputs and outputs
Every action is a small contract. It declares the inputs it needs and the outputs it returns.
- An input is a value the action needs to run, such as a record Id, a name to search for, or a new field value.
- An output is a value the action sends back, such as a record, a summary, or a count.
Each input and output has a name, a data type, and a description. An input can be required or optional. The agent reads these definitions to understand what the action does and what to pass to it.
The Apex example from the topic plan shows this contract in code. Request defines one required input, accountId. Result defines one output, openCases. The description text on each variable is what the agent reads.
Slot filling
Slot filling is how the agent gets a value for each input. The agent looks for the value in three places, in this order of preference:
- The user's message. If the user says "Summarize the Acme account," the agent can use "Acme" as the name to search for.
- The conversation so far. Earlier messages, and outputs from earlier actions, can supply values.
- The user, by asking. If a required input is still empty, the agent asks a follow-up question.
You can steer this behavior in two places. In the action's input settings, you can mark an input as required, and you can control whether the agent may collect it from the user. In the topic instructions, you can say where a value should come from. The topic example does this with "first find the account record, then use the result for any later step."
A worked example
Take the Account Support topic. A user writes: "Update the phone number for Acme."
- The agent picks a lookup action. Its input is the account name. The agent fills it with "Acme" from the message.
- The lookup returns an account record Id. That is an output.
- The agent picks an update action. It needs the record Id and the new phone value. The Id comes from step 2. The phone number is missing, so the agent asks: "What is the new phone number?"
- After the user answers, the topic instruction requires a confirmation. The agent restates the field and value, and runs the update only after the user agrees.
Outputs from step 2 became inputs in step 3. This is the core of how actions combine, and a later chapter covers it further.
Common errors
- Vague descriptions. If an input is described as "Id," the agent may pass the wrong value. Write "The Id of the account to update."
- Wrong type. An input that expects a record Id will fail if the agent passes a name. Look up the record first.
- Guessing. An agent may fill an input with a plausible but wrong value. Add an instruction such as "If you cannot find exactly one matching record, ask the user to clarify."
- Unused outputs. An output the agent never reads does nothing. Reference it in instructions if later steps depend on it.
Exercise
A user says "Show me the open cases for Globex." The lookup action returned the account Id, and the next action needs an Id and a status filter. The user did not mention a status. Where does the Id come from, and what does the agent do about the status?
Show answer
The Id comes from the output of the lookup action, taken from the conversation. The user gave no status and the conversation has none, so if the status input is required, the agent asks the user for it. If it is optional, the agent can run the action without it.