Sub topic 3
Mapping Prompt Template Action Inputs and Outputs
Assume you know Salesforce objects, records, permissions, and the basic parts of an Agentforce agent. A prompt template action connects an agent topic to a prompt template. The action supplies input values, and the template returns generated text.
Map inputs and outputs
Create action inputs that match the resources defined by the template. For example, a template using Input:Case needs a Case record as its input. The agent can obtain the record from the conversation or from a previous action.
The generated response is usually returned as text. Configure the topic to present that output directly when the template already controls its format.
| Part | Responsibility |
|---|---|
| Action input | Supplies a record, field value, or other template resource |
| Prompt template | Combines instructions with the supplied data |
| Action output | Returns the generated text to the topic |
flowchart LR
U[User request] --> T[Agent topic]
T --> A[Prompt template action]
A --> P[Prompt template]
P --> R[Generated text]
R --> T
T --> Ucaption: How data moves through a prompt template action alt: A flow from the user to an agent topic, then to an action and prompt template, and back as generated text
Test and debug
Preview the template in Prompt Builder with representative records. Check whether the merge fields contain the expected values. Then test the complete conversation in Agent Builder.
Debug in this order:
- Confirm that the topic recognizes the request.
- Confirm that the topic identifies the correct record.
- Confirm that the action receives every required input.
- Compare the action output with the Prompt Builder preview.
- Check whether topic instructions accidentally rewrite or omit the output.
If a field is blank, verify record access, field-level security, and the merge field path. If the wrong action runs, make the topic scope and action instructions more specific.
Versions and activation
Save changes as a new template version when possible. Test the version before activating it. Only one version should be the active production version. Keep the previous version available so you can roll back after a faulty change.
Call the template from Flow or Apex
Use Flow when an administrative process needs the same generated text. Use Apex when code must control the call or handle the result programmatically.
ConnectApi.EinsteinPromptTemplateGenerationsInput input =
new ConnectApi.EinsteinPromptTemplateGenerationsInput();
input.isPreview = false;
input.inputParams = new Map<String, ConnectApi.WrappedValue>();
ConnectApi.WrappedValue caseValue = new ConnectApi.WrappedValue();
caseValue.value = new Map<String, String>{ 'id' => caseId };
input.inputParams.put('Input:Case', caseValue);
ConnectApi.EinsteinPromptTemplateGenerationsRepresentation result =
ConnectApi.EinsteinLlm.generateMessagesForPromptTemplate(
'Summarize_Case', input);
String summary = result.generations[0].text;Design practices and pitfalls
- Give inputs clear names and document their expected type.
- Tell the template what to do when data is missing.
- Keep formatting rules in one place.
- Avoid passing more fields than the task needs.
- Test empty, unauthorized, and unusually long records.
- Do not assume the model will preserve unsupported claims or dates.
Exercise
A case summary action returns an empty subject even though the Case has a subject. What should you check first?
Show answer
Check the merge field path, the action-to-template input mapping, and the running user's field-level access to Subject.