How to Manage Agentforce Prompt Templates
Outcome
By the end of this tutorial, you will understand how to create, organize, version, and deploy prompt templates in Salesforce Agentforce. You'll know how to structure templates for consistency, manage template variants, and integrate them into your agent workflows without manual configuration overhead.
Prerequisites
- Salesforce org with Agentforce enabled
- Access to Agentforce setup and configuration
- Basic familiarity with Agentforce agent builder
- Understanding of prompt engineering fundamentals (system prompts, roles, instructions)
Step 1: Understand the Template Hierarchy
Agentforce templates exist at different levels. A template is a reusable prompt structure that defines how your agent communicates and behaves. Templates can be stored at the org level (shared across all agents), at the agent level (specific to one agent), or as part of a template library.
Start by accessing the Agentforce Templates section in your Salesforce org. Navigate to Setup > Agentforce Configuration > Templates. Here you'll see existing templates and the option to create new ones. The key distinction is whether you want a global template (used by multiple agents) or a context-specific one (tightly coupled to a single agent's workflow).
Step 2: Structure Your Base Template
A well-structured template begins with a clear role definition and context. Open a new template and divide it into sections: role, context, constraints, and instructions.
Role: You are a [specific role] assistant within a [business context].
Context: You handle [primary domain]. Your interactions involve [typical scenarios].
Constraints: Always [core behavioral rule]. Never [prohibited action].
Instructions: When addressing [common scenario], follow this pattern: [step-by-step approach].
This structure makes templates predictable and easier to modify. Fill in the bracketed sections with your specific requirements. For a customer service agent, your role might be "knowledgeable support representative," your context might be "e-commerce returns and refunds," your constraints might include "stay within documented policies," and your instructions might outline escalation paths.
Save this template with a clear name: customer-service-base-v1 rather than template-1. Versioning in the name is critical when you have multiple iterations.
Step 3: Create Template Variants for Different Personas
Different use cases often need slight variations on your base template. Rather than creating entirely new templates, inherit from your base and override specific sections.
In Agentforce, templates support inheritance. Create a new template and reference your base: select Create from Template > customer-service-base-v1. Agentforce copies the base template. Now modify only the sections that differ.
For example, if you have a separate technical support agent, create technical-support-v1 from the base. Keep the role, context, and constraints identical, but extend the instructions with technical troubleshooting steps. This approach reduces duplication, ensures consistency, and makes updates easier — a single change to the base template can cascade to all children.
Step 4: Implement Template Parameters
Hardcoding values into templates creates maintenance nightmares. Agentforce templates support dynamic parameters using the {{variable}} syntax.
Edit your template to include parameters:
Role: You are a {{role_title}} within {{organization_context}}.
Context: You handle {{primary_domain}}. Your knowledge cutoff is {{knowledge_date}}.
Instructions: Escalate issues requiring {{escalation_criteria}} to the {{escalation_team}}.
When you assign this template to an agent, you'll specify values for each parameter. This lets you reuse the same template across different agents by injecting context-specific values at runtime. For instance, the same customer-service template can serve different regional offices by parameterizing language tone, local policies, or business hours.
Step 5: Organize Templates in a Library
As templates accumulate, organization becomes essential. Create a naming convention and folder structure within your Agentforce Templates section.
Use a prefix that indicates the template's category and version:
cs-base-v1(customer service base template, version 1)cs-billing-v1(customer service billing variant)ts-technical-v1(technical support)sales-lead-qualification-v1(sales agent)
Document your naming scheme in a README or wiki page that your team can reference. Include the template's purpose, its parameters, and which agents use it. This prevents duplicate templates and clarifies which version is production-ready.
Step 6: Version and Track Changes
Prompt performance evolves. When you refine a template, don't overwrite the old version — create a new one.
If you have customer-service-base-v1 and you want to improve it, create customer-service-base-v2 with your refinements. Keep v1 assigned to live agents until you've tested v2. This gives you a rollback path and historical record of what worked.
Document the differences between versions in the template description field. Write something like:
v2 changes: Added explicit tone guidance (professional but friendly).
Clarified refund policy reference. Expanded timeout handling for waiting scenarios.
Changed from reactive to proactive tone in greeting section.
When you're confident in v2, gradually migrate agents from v1 to v2. Monitor their performance metrics (resolution rates, customer satisfaction, escalation rates) to validate the change.
Step 7: Integrate Templates into Agent Workflows
Templates are most powerful when integrated early in your agent's lifecycle. When creating a new agent in the Agentforce builder, select Use Template and choose your variant.
The builder will populate the agent's system prompt with your template's content. From there, you can add agent-specific customizations — additional instructions, knowledge sources, tools, and integrations — while keeping the core prompt template consistent.
Your agent now inherits benefits of template management: future updates to the template are easier to cascade, testing becomes standardized, and onboarding new agents is faster because you're not starting from a blank prompt each time.
Step 8: Test and Refine Before Production
Before deploying a template to a live agent, run it through a test scenario. Create a test agent, assign the template, and execute a few test conversations covering edge cases.
Document what you're testing:
- Does the agent understand its role correctly?
- Does it adhere to constraints (no prohibited actions)?
- Does it follow the instructed reasoning pattern?
- Are parameters interpolated correctly?
- Does it handle ambiguous or out-of-scope requests?
Capture sample outputs. If behavior is unexpected, refine the template language, re-test, and iterate. Only move the template to production once test results are consistent.
Pitfalls and Troubleshooting
Pitfall 1: Over-parameterization
Templates with too many parameters become hard to manage. Every parameter requires documentation and validation at runtime. Start with 3–5 key parameters and add more only when you have multiple agents using the same template with genuinely different values.
Fix: Review your parameters quarterly. Consolidate or remove parameters that no one is actually changing between agents.
Pitfall 2: Forgetting to version
Overwriting a template without backing up the old version is risky. An agent might depend on the old wording, and you lose the history of what changed.
Fix: Establish a rule: never update a template in place. Always create a new version and migrate agents deliberately.
Pitfall 3: Templates Drifting Out of Sync
After deployment, an agent's system prompt can diverge from its template if developers manually edit the prompt directly in the agent. This breaks your ability to manage the template as a source of truth.
Fix: Make templates read-only in your workflow. If an agent needs a change, update the template and re-assign it to the agent, rather than hand-editing the agent's prompt.
Pitfall 4: Unclear Parameter Names
A parameter named {{context}} is ambiguous. You end up with incomplete documentation and confusion about what value to supply.
Fix: Use specific parameter names: {{customer_service_context}}, {{technical_depth_level}}, {{escalation_team_name}}. The name should answer "what is this for?"
Recap
You've learned to create a base template, structure it for clarity, define variants, add parameters for flexibility, organize templates in a library with a naming convention, version templates to track changes, integrate them into agents, test them before production, and avoid common pitfalls.
Your next step is to audit your existing Agentforce agents, identify common prompt patterns, and extract them into templates. Start with one template (your most-used agent archetype), migrate one agent to it, measure the outcome, and expand from there. This incremental approach ensures your template strategy adds real value without requiring a wholesale rewrite of your agent fleet.

