Invoking Salesforce Prompt Templates as actions within Agent Script.
---
## Overview
Prompt Template Actions let agents invoke Salesforce Prompt Templates via the `generatePromptResponse://` protocol. The agent passes structured inputs to the template and receives a generated `promptResponse` output — keeping content generation in the template while the agent manages conversation flow.
**When to use**: Personalized responses, summarization, content generation, recommendations — anything where an LLM prompt template produces better output than static Flow logic.
---
## Action Definition (Agentforce Assets)
Define the action in **Setup > Agentforce > Action Definitions** (or via metadata API):
```agentscript
actions:
Generate_Personalized_Schedule:
description: "Generate a personalized schedule using a prompt template"
inputs:
"Input:email": string
description: "User's email address"
is_required: True
"Input:preferences": string
description: "User's scheduling preferences"
is_required: False
outputs:
promptResponse: string
description: "The personalized schedule generated by the template"
**Input binding patterns** (same as regular actions):
-`@variables.user_email` — variable binding (data from prior turns)
-`...` — LLM slot-filling (extract from conversation)
-`"professional"` — fixed value (business rule constant)
---
## Grounded Data Integration
Templates can include **data providers** (Apex classes, Flows) that supply contextual data for personalized responses. The grounding happens inside the template — Agent Script only needs to pass the lookup key:
```agentscript
actions:
Get_Product_Recommendations:
description: "Generate personalized product recommendations based on purchase history"
inputs:
"Input:customerId": string
description: "Customer ID for personalization"
is_required: True
outputs:
promptResponse: string
description: "Personalized recommendations grounded in customer data"