Agentforce Prompt Builder & Prompt Templates Guide 2026

📅  Agentforce
Agentforce Course — Module 6: Prompt Builder | sfinterviewpro.com
🤖 Free Agentforce Course 2026 — sfinterviewpro.com
✨ Module 6 of 15

Prompt Builder
Grounded AI Prompts

Master Prompt Builder — create reusable prompt templates grounded in your Salesforce data. Learn all 4 template types, how grounding works (data + context = smarter responses), and invoke prompts from your Subagents and Actions. Your agent levels up to DATA-AWARE AI!

4
Template Types
3
Grounding Methods
100%
Data-Aware
Reusable
Prompts
📍 Course Progress — Module 6 of 15
Intro
Trust
DevOrg
Builder
TIA
M6Prompt
M7Std Act
M8Flow
M9Apex
M10API
M11Data
M12Deploy
M13Scale
M14Test
M15Done
🎯 What You'll Master in This Module
Prompt Builder basics (4 template types). Grounding fundamentals (how to add Salesforce data context to prompts). All 3 grounding methods (Record Context, Data Table, Free-Form). Real XYZ Company prompt examples. Invoking prompts from Subagents. Interview patterns. By end, you'll build data-aware prompts that make agents 10x smarter!
💡 What is Prompt Builder?
Prompt Builder is Salesforce's no-code interface for creating prompt templates — reusable AI instructions grounded in your Salesforce data. Create once, use everywhere. Template = a prompt with placeholders that Agentforce fills in with real data from CRM. Einstein Trust Layer protects all data automatically.
📚

Part 1: Prompt Builder Fundamentals

What is a prompt template? 4 template types. When to use each.

A prompt template is a reusable prompt WITH PLACEHOLDERS that Agentforce fills with real Salesforce data. Static part = your instructions. Dynamic part = data from CRM. Example: “Summarize Account {{AccountName}}: {{AccountDescription}}.” When invoked, {{AccountName}} becomes “ABC Pharma”.
1
The 4 Prompt Template Types
Know which to use when
Template TypePurposeWhen to UseExample Output
Field GenerationGenerate or fill a single field value using AIAuto-fill email subject, lead source, next step fieldGenerate email subject from Account name & Opportunity stage
Record SummaryCreate a summary of a single recordSummarize Account for sales rep, brief case overview“ABC Pharma: Healthcare, Mumbai-based, $50M revenue, key contact Rajesh...”
Sales EmailGenerate customized email to customerDraft follow-up emails, outreach, objection handlingProfessional email to Rajesh at ABC Pharma w/ personalized details
Custom (Unrestricted)Any AI task using Salesforce dataCompetitive analysis, deal strategy, risk assessmentBI-generated risk analysis for Opportunity based on stage, days open, etc.
✅ Pro Tip: Start with Guided Templates
Field Generation, Record Summary, Sales Email are “guided” — Prompt Builder helps you build them visually. Custom is freeform — write your own prompt from scratch. For learning, use guided templates first!
2
Create Your First Prompt Template: Account Summary
XYZ Company example — follow step by step
a
Go to Setup — Quick Find: Prompt Builder
b
Click New Prompt Template
c
Choose Record Summary type
d
Fill in template details:
📋 Template Configuration
Template Name: Account Summary for Sales
Description: Generates a 2-3 sentence business summary of any Account for sales reps
Object: Account
Prompt Text:

Summarize the following Salesforce Account in 2-3 professional sentences for a sales representative:

Account Name: {{Account.Name}}
Industry: {{Account.Industry}}
Description: {{Account.Description}}
Annual Revenue: {{Account.AnnualRevenue}}
Employees: {{Account.NumberOfEmployees}}
Location: {{Account.BillingCity}}, {{Account.BillingState}}

Include: What they do, why they matter as a customer, key insight for engagement.
Keep professional tone. Max 150 words.
e
Click Test to preview. Select an Account (e.g., “ABC Pharma”). See it generate a summary!
f
Click Save
🎉 Your First Prompt Template!
You've created a reusable prompt! Every time an agent (or a user) invokes this template with an Account, it generates a fresh summary. This is the power of Prompt Builder — write once, use everywhere!
🎯

Part 2: Grounding — The Secret Sauce

Add Salesforce data context to prompts. Why it matters. How it works.

Grounding = adding real Salesforce data to your prompt as context. Without grounding, AI is generic (“Account is a business entity...”). With grounding, AI is smart (“ABC Pharma is a $50M healthcare manufacturer, key contact Rajesh, open opportunity for tubing...”). Grounded AI = data-aware AI = better responses!
1
Why Grounding Matters — Before vs. After
The difference between generic and smart AI
❌ Without Grounding
User: “Draft email to ABC Pharma”

AI generates: “Dear ABC Pharma, we offer silicone solutions for various industries...” (generic, no context)
✅ With Grounding
User: “Draft email to ABC Pharma”

AI generates: “Dear Rajesh, Thank you for your interest in pharma-grade tubing. As discussed, we can customize the tubing for your production line upgrade. Based on your 500-person team & $50M revenue, we recommend our Medical Grade Variant 3...” (personalized, data-aware)
💡 Grounding Rule
Always ground prompts when they reference CRM data. User says “Email this customer” — ground the prompt with Customer data. Agent needs to “summarize this deal” — ground with Opportunity & Account data. No grounding = generic responses. Grounding = smart responses.
2
3 Ways to Ground Prompts
Record Context, Data Table, Free-Form Input
Grounding MethodHow It WorksWhen to UseExample
Record ContextTemplate tied to a specific object (Account, Opportunity). Prompt accesses {{Record.FieldName}} variables from that record.Summarize single record, draft email to customer, generate field value. Most common!{{Account.Name}}, {{Account.Industry}}, {{Opportunity.Amount}}
Data TablePass multiple records as a table inside prompt. AI processes table of data.Compare multiple opportunities, analyze account portfolio, summarize competitor listTable of top 5 open Opps w/ stage, amount, days open — AI analyzes & prioritizes
Free-Form InputUser (or Action) passes text directly into prompt. Not tied to specific CRM record.Competitive analysis, strategy brainstorm, risk assessment. Any prompt that needs custom input.User pastes deal notes, AI generates risk analysis. No record lookup needed.
✅ Most Common: Record Context
99% of templates use Record Context. Template is tied to Account/Opportunity/Contact. Prompt accesses fields via {{Record.FieldName}}. Simple, reliable, Enterprise-grade.
3
Create Grounded Prompt: Sales Email (Record Context)
Follow along — template that uses Account data
a
New Prompt Template — Choose Sales Email type
b
Object: Account (so it's tied to Account records)
c
Template Name: Personalized Sales Email to Account
d
Prompt Text (copy exactly):
You are a professional sales representative for XYZ Company. Draft a personalized email to the primary contact at {{Account.Name}}. ACCOUNT CONTEXT (GROUNDING): Company: {{Account.Name}} Industry: {{Account.Industry}} Location: {{Account.BillingCity}}, {{Account.BillingState}} Website: {{Account.Website}} Annual Revenue: {{Account.AnnualRevenue}} Number of Employees: {{Account.NumberOfEmployees}} Description: {{Account.Description}} EMAIL REQUIREMENTS: - Personalized greeting (address decision-maker by title & company, not generic “Dear Sir/Madam”) - Reference their industry & company specific details (shows research) - Mention how XYZ products solve their specific challenges (NOT generic pitch) - Include 1 relevant case study hint (e.g., “Similar pharma manufacturers saw 30% efficiency gain...”) - Clear call-to-action (meeting, demo, question) - Professional, warm tone (not pushy) - Max 150 words Generate email now:
📋 Test This Template
Select Account: ABC Pharma
Click Test — watch AI generate a personalized email to ABC Pharma referencing their industry (Healthcare), location, revenue, etc. WITHOUT grounding, it would be generic. WITH grounding, it's personalized!

Notice: Every field {{Account.Name}}, {{Account.Industry}}, etc. gets replaced with real data from ABC Pharma record in Salesforce. That's grounding power!
4
Data Table Grounding: Compare Opportunities
Pass a table of multiple records
Data Table grounding lets you pass multiple CRM records as a table. Agent queries open Opportunities, Prompt Builder formats them as a table, prompt analyzes. AI can prioritize, compare, spot patterns.
📋 Data Table Template: Opportunity Prioritization
Template Name: Prioritize Open Opportunities

Prompt Text:
“I will give you a table of open Opportunities. Analyze and rank them by winning probability (highest to lowest). Consider: days in stage, customer history (repeat buyer?), opportunity size, recent activity.”

Table (Grounding):
Opportunity ID | Account | Amount (₹) | Stage | Days in Stage | Last Activity
OPP-001 | ABC Pharma | 2,500,000 | Proposal | 12 | 2 days ago
OPP-002 | MedTech | 1,800,000 | Negotiation | 25 | 7 days ago
OPP-003 | BioLife | 350,000 | Qualification | 5 | Today

AI Output:
1. OPP-001 (ABC Pharma) — 85% win prob. New stage, recent activity, repeat customer — FOCUS HERE
2. OPP-002 (MedTech) — 65% win prob. In negotiation but inactive 7 days — nudge for update
3. OPP-003 (BioLife) — 40% win prob. Early stage, small deal — nurture only
✅ When to Use Data Table
Analyze multiple records at once. Compare opportunities, review account portfolio, evaluate leads. Any prompt that benefits from seeing “the whole picture” = use Data Table grounding.

Part 3: Invoking Prompts from Your Agent

Call prompt templates from Subagents. Invoke from Standard Actions, Flows, Apex.

Once you create a prompt template, invoke it from your Subagent to execute. Method depends on where you want to call it: Standard Action (simple), Flow (visual), Apex (complex). Each method fetches the prompt + data + runs AI.
1
Invoke Prompt via Standard Action (Simplest)
No code. Visual. Fastest way to start.
a
In Agent Builder — Open your Subagent (e.g., Sales Handler)
b
Canvas View — Add Action block (plus icon)
c
Search for your prompt template (e.g., “Account Summary for Sales”)
d
Configure inputs: Choose which Record ID to pass. Agent fills automatically with context.
e
Save. Now when user says “Summarize ABC Pharma” — agent invokes this action — prompt runs — summary appears!
✅ That's It!
Standard Action invoke is no-code. Pick your prompt template. Configure record input. Done! Agent can now call it anytime.
2
Invoke Prompt via Flow (Complex Logic)
Visual workflow that calls prompt
Use Flow when you need logic BEFORE or AFTER prompt. Example: Query multiple opportunities — loop through each — call prompt template for each — collect results — format response.
📋 Flow Example: Batch Opportunity Analysis
Flow Name: GenerateSummaryForAllOpenOpps

Flow Steps:
1. Query: GET all open Opportunities for Account X
2. Loop: For each Opportunity
   a. Invoke prompt template: “Opportunity Summary” for this Opp
   b. Collect summary text
3. Combine: Merge all summaries into one response
4. Return: Send combined summary to agent

Why Flow? Querying multiple records + looping + calling prompt multiple times. Standard Action can't do this. Flow handles it visually!
✅ Flow Process
In Flow Builder, add action “Invoke Prompt Template.” Pass record data. Flow continues after prompt completes. Use for multi-step processes!
3
Invoke Prompt via Apex (Custom Integration)
Most control. For advanced devs.
// Invoke Prompt Template from Apex String promptTemplateId = 'FPC_xxxxxx'; // Your prompt template ID String recordId = 'a03xx000001zzz'; // ABC Pharma Account ID // Invoke prompt PromptBuilderService.InvokePromptRequest request = new PromptBuilderService.InvokePromptRequest(); request.setPromptTemplateId(promptTemplateId); request.setContextRecordId(recordId); PromptBuilderService.InvokePromptResult result = PromptBuilderService.invokePrompt(request); String generatedText = result.getGeneratedText(); System.debug('Generated Summary: ' + generatedText); // Use generatedText in your agent response // Example: Send email, update field, return to user
⚠️ Apex Invocation
Requires dev skills. Get prompt template ID from setup. Pass record ID. Receive generated text. Use when Standard Action or Flow not sufficient!
💡

Part 4: Prompt Template Best Practices

How to write world-class templates. Avoid common mistakes.

1
Writing Perfect Prompts — 5 Rules
Every template should follow these
RuleWhat It MeansGood ExampleBad Example
1. Be SpecificTell AI exactly what to do, not vague requests“Summarize this Opportunity: stage, amount, key risks, next steps. 100 words max.”“Analyze this opportunity”
2. Provide ContextGive AI the data it needs (grounding!)Include {{Account.Industry}}, {{Opportunity.Stage}}, {{Account.AnnualRevenue}} in promptNo field variables — make AI guess
3. Set ConstraintsWord limit, format, tone“150-200 words. Professional tone. Bullet points for readability.”No limits. AI rambles.
4. Include ExamplesShow AI what good output looks like (few-shot)Include 1 sample summary showing desired structure & depthExpect AI to guess what format you want
5. Test ThoroughlyUse Test feature. Try with different recordsTest with ABC Pharma, MedTech, BioLife. Verify quality is consistentCreate template once, never test, deploy broken
✅ Template Quality = AI Output Quality
Vague prompt = vague output. Specific prompt with grounding + constraints + examples = excellent output. Spend time on your templates!
2
Common Mistakes to Avoid
Anti-patterns that break templates
❌ No Grounding
Prompt has no field variables. Generic responses.
✅ Grounded
Prompt includes {{Account.Name}}, {{Account.Industry}}, etc. Personalized responses.
❌ Too Vague
“Write an email about this customer” — AI guesses tone, length, details
✅ Specific
“Draft a follow-up email (150 words, professional tone) with 1 specific product recommendation based on their industry.”
❌ No Testing
Deploy template without testing. Broken in production.
✅ Well Tested
Test with 3-5 different records. Verify output quality is consistent before invoking from agent.
3
Naming Conventions — Organize Your Templates
Keep 10+ templates organized
📋 Naming Template
[Object]_[Action]_[Purpose]

Examples:
— Account_Summary_ForSales
— Opportunity_RiskAnalysis_ForManager
— Contact_Email_InitialOutreach
— Case_NextSteps_ForSupport
✅ Benefit
Easy to find templates. Self-documenting. When Subagent invokes “Account_Summary_ForSales,” everyone knows what it does!
🎤

Prompt Builder — Interview Questions

Real questions from Agentforce developer interviews

Interview QuestionBest Answer
What is a prompt template?A reusable prompt with placeholders ({{FieldName}}) that Agentforce fills with real Salesforce data. Static part = your instructions. Dynamic part = CRM data. Create once, invoke many times from agent/Actions.
Explain grounding and why it mattersGrounding = adding Salesforce data context to prompts. Without grounding, AI is generic. With grounding, AI is personalized & data-aware. Example: “Draft email to {{Account.Name}} in {{Account.Industry}}” — AI uses real Account data to customize response.
Describe the 3 grounding methods1. Record Context: Prompt tied to Account/Opp, uses {{Record.FieldName}} (most common). 2. Data Table: Pass multiple records as table, AI analyzes. 3. Free-Form: User passes text directly, no record lookup needed.
When would you use Data Table grounding?When you need AI to analyze multiple records at once. Examples: compare 5 open opportunities, review account portfolio, evaluate lead list. Any “see the whole picture” prompt = use Data Table.
How do you invoke a prompt from a Subagent?3 ways: (1) Standard Action — select template visually, configure record input. (2) Flow — invoke template action in workflow, good for loops/multi-step. (3) Apex — call PromptBuilderService API for custom logic.

Module 6 Summary — Prompt Builder Mastered

What you know now

  • 4 Template Types: Field Generation, Record Summary, Sales Email, Custom. Know when to use each.
  • Grounding Power: Add Salesforce data context to prompts. Without grounding = generic. With grounding = smart, personalized responses.
  • 3 Grounding Methods: Record Context ({{Record.FieldName}}, most common), Data Table (analyze multiple records), Free-Form (custom text input).
  • How to Create: Setup — Prompt Builder — Choose Type — Add grounding fields — Test — Save.
  • How to Invoke: Standard Action (simplest), Flow (visual, complex logic), Apex (custom). Pick based on use case.
  • 5 Best Practices: Be Specific, Provide Context, Set Constraints, Include Examples, Test Thoroughly.
🎉 You're Now Data-Aware!
You can create grounded prompts that use real Salesforce data. Your agent is no longer generic — it's smart, personalized, and context-aware. This is what makes Agentforce powerful!
🧠 Module 6 — Knowledge Check
Q1: What is a prompt template? — A reusable prompt with placeholders ({{FieldName}}) that Agentforce fills with real Salesforce data. Create once, invoke many times.
Q2: Why is grounding important? — Without grounding, AI is generic. With grounding (adding data context), AI is personalized & data-aware. “Summarize {{Account.Name}} in {{Account.Industry}}” uses real data to customize response.
Q3: What's the most common grounding method? — Record Context. Prompt tied to Account/Opportunity/Contact. Uses {{Record.FieldName}} variables. Most templates use this.
Q4: When would you use Data Table grounding? — When AI needs to analyze multiple records at once. Compare opportunities, review portfolio, evaluate leads. Any “big picture” analysis prompt.
Q5: How do you invoke a template from Subagent? — 3 ways: Standard Action (simplest, visual), Flow (complex logic, loops), Apex (custom code). Pick based on use case.

🚀 Ready for Module 7?

Next: Standard Actions Deep Dive — Master Get, Query, Create, Update You'll learn every Standard Action type with real examples. This is where your agent performs CRUD operations on Salesforce data like a boss!

Module 7: Standard Actions —
SF
By SF Interview Pro
Salesforce Interview Prep Team
Practical Q&A by working Salesforce professionals · LWC, Apex, Data Cloud & AI
About Us ↗
☕ Enjoyed this article?
SF Interview Pro is 100% free and maintained by a Salesforce professional. No ads, no paywalls, and no signup required. If this guide helped you prepare for an interview, earn a certification, or grow your Salesforce career, consider buying me a coffee! ☕💜
🇮🇳 UPI (India)
UPI QR Code to support sfinterviewpro
Pay by QR
GPay · PhonePe · Paytm · BHIM
🌎 International
PayPal QR Code to support sfinterviewpro Pay via PayPal ↗
Scan or tap to pay