Sub topic 2
Defining Input and Output Variables
Assume you know Salesforce objects, fields, records, and basic Flow Builder elements. You should also understand permission sets and the general role of an AI agent.
Define the action contract
An Agentforce action needs a clear contract with two kinds of flow variables:
- An input variable receives a value from the agent, such as a case number.
- An output variable returns a value for the agent to use in its reply.
Set isInput to true for values the agent can provide. Set isOutput to true for values the agent should receive. Use descriptions to explain the meaning, format, and purpose of each variable.
<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>Write descriptions the agent can use
Descriptions are operational guidance for the language model. Name the business value, not only the field type. State valid formats and what the agent should do when a value is missing.
For example, tell the agent to collect caseNumber from the user and ask for it when necessary. Tell it to present caseStatus in plain language.
Build the flow logic
Use an autolaunched flow with no trigger. A typical sequence is:
- Receive
caseNumber. - Use Get Records to find the matching Case.
- Use a Decision element to test whether a record was found.
- Assign the Case Status to
caseStatus. - Assign a useful message when no record exists.
- Update records only when the action is explicitly designed to change data.
Return useful failures
Add fault paths to elements that can fail. Set the output variable to a short, safe message such as “The case could not be retrieved.” Do not expose stack traces, record identifiers, or internal permissions details to the customer.
Control context and access
Choose the flow’s run context deliberately. The context determines whose permissions and sharing rules affect data access. Give the flow only the object and field permissions it needs. For updates, verify that the running user or designated context can modify the target records.
Exercise
Why should a flow return an output message when Get Records finds no case?
Show answer
The agent needs a defined result so it can explain the outcome instead of guessing or producing an empty reply.