🏠 Home 🔒 Record Sharing ⚙ Apex Triggers 🔍 SOQL 💻 LWC 🔗 Integration 🤖 Flows & Automation 🤖 Agentforce & AI 🎈 Agentforce Course — Free ☁ Data Cloud 🎓 DC Course — Free 💵 CPQ 🎯 100 Scenario Questions 🏆 150 Advanced Questions 📧 Marketing Cloud 🏗️ Company Wise 👥 About Us Start Learning Free →

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 —
AI-Powered Templates for Your Agent

Create reusable AI prompt templates grounded in real Salesforce data. Build a Follow-up Email template for XYZ Sales Assistant — and watch AI generate professional emails from actual Account and Opportunity records.

3
Template Types
3
Templates Built
Live
AI Generation
Zero
Code Needed
📍 Course Progress — Module 6 of 15
What is Agentforce
Trust Layer
Dev Org Setup
Agent Builder
TIA Framework
M6Prompt Builder
M7Std Actions
M8Flow Actions
M9Apex Actions
M10API Actions
M11Data Cloud
M12Deploy
M13Escalation
M14Testing
M15Full Project

1. What is Prompt Builder?

Reusable AI prompts grounded in real Salesforce data

Prompt Builder is a no-code tool in Salesforce Setup where you create reusable AI prompt templates that are grounded in real Salesforce data. Instead of writing the same AI prompt every time, you build a template once — it automatically pulls in real record data as context, sends it to the LLM, and returns a polished AI-generated output.
💡 Simple Analogy
Think of Prompt Builder like a mail-merge email template — but instead of just filling in a name and address, it fills in your entire Salesforce record data and asks an AI to write a professional email using all that context. The AI writes a genuinely personalized, intelligent response — not a generic template.
Setup → Prompt Builder → Follow-up Email Template
📝 Prompt Template (You Write This)
You are a professional sales rep at XYZ Company.
Write a follow-up email to:
{!$Input:Contact.FirstName} {!$Input:Contact.LastName}
Title: {!$Input:Contact.Title}
Company: {!$Input:Account.Name}

Re: Opportunity: {!$Input:Opportunity.Name}
Stage: {!$Input:Opportunity.StageName}
Amount: {!$Input:Opportunity.Amount}

Keep it professional, warm, and under 150 words.
🤖 AI Generated Output (Preview)
Subject: Following Up — MedTech Device Seals Partnership

Dear Priya,

I hope this message finds you well. I wanted to follow up on our discussion regarding the Annual Device Seals contract for MedTech Solutions India.

We're currently in the Negotiation stage and I'm confident we can finalize terms that work well for both teams. The proposed value of ₹18,00,000 reflects our commitment to a long-term partnership.

Would you be available for a brief call this week to move things forward?

Best regards,
XYZ Company Sales Team
🌍 XYZ Company — Why Prompt Builder Changes Everything
Before Prompt Builder: Sales rep spends 15 minutes writing a follow-up email, manually looking up contact name, opportunity details, and history.

After Prompt Builder: Sales rep clicks "Draft Email" in Agent — AI pulls Priya Sharma's details + MedTech opportunity data + writes a professional 150-word email in 3 seconds. Rep reviews, adjusts if needed, sends. 15 minutes → 30 seconds.
📋

2. The 3 Types of Prompt Templates

Each type serves a different use case — know when to use which

📝
Field Generation
AI generates a value for a specific Salesforce field based on other record data. Auto-populates fields intelligently.
Auto-fill fields
📊
Record Summary
AI summarizes a Salesforce record — account history, case details, opportunity status — into a readable paragraph.
Summarize records
✉️
Sales Email
AI drafts a complete email grounded in opportunity, account, and contact data. Used directly in email composers and agents.
Draft emails
Template TypeOutputTriggered ByXYZ Company Use Case
Field GenerationSingle field valueButton click on record page, Agent actionAuto-generate Account Description from industry + size data
Record SummaryMulti-paragraph summaryEinstein Copilot, Record page panel, Agent actionSummarize ABC Pharma Account: key contacts, open deals, recent activity
Sales EmailComplete email draftOpportunity email composer, Agent actionDraft follow-up email to Rajesh Mehta re: Silicone Tubing opportunity
🎯 Which Type Do We Build in This Module?
All 3! We build:
1. Sales Email — Follow-up email for XYZ Sales Assistant agent (main template)
2. Record Summary — Account summary for quick briefings
3. Field Generation — Auto-generate opportunity next steps

The Sales Email template connects directly to the agent as an Action in Module 7.
🔗

3. Merge Fields — How Grounding Works

How real Salesforce data gets into your AI prompt

Merge fields are placeholders in your prompt template that get replaced with real Salesforce data before being sent to the AI. This is called grounding — anchoring the AI in factual, real-time Salesforce data so it generates accurate, contextual responses instead of generic hallucinations.
📊 Salesforce
Record Data
🔗 Merge Fields
Populated
🤖 LLM Receives
Full Context
✅ Accurate AI
Response
📋 Merge Field Syntax — Prompt Builder
{!$Input:Contact.FirstName}
Contact's first name from the current record
{!$Input:Account.Name}
Account name linked to the current record
{!$Input:Opportunity.StageName}
Current stage of the Opportunity record
{!$Input:Opportunity.Amount}
Deal amount from the Opportunity record
{!$Input:Opportunity.CloseDate}
Expected close date of the deal
{!$Input:Account.Industry}
Industry field from related Account
{!$Input:Contact.Title}
Contact's job title
⚡ Why Grounding Matters
Without grounding: AI writes "Dear Customer, I wanted to follow up on your recent inquiry..." — generic, unhelpful.

With grounding: AI writes "Dear Priya, Following our discussion about MedTech's annual device seals contract (₹18,00,000 — currently in Negotiation stage)..." — specific, professional, instantly useful.

Grounding is what makes AI responses ACCURATE. Without it, AI hallucinates facts.
1
Build Template 1 — Sales Follow-up Email
The main template used by XYZ Sales Assistant agent
a
Go to Setup → Quick Find: "Prompt Builder" → Click Prompt Builder
b
Click "New Prompt Template" button
c
Select template type: "Sales Email"
d
Fill in template details:
FieldValue to Enter
Template NameXYZ Follow-up Email
API NameXYZ_Followup_Email (auto-filled)
DescriptionGenerates a professional follow-up email for XYZ Company sales reps based on Opportunity and Contact data
Primary ObjectOpportunity
Related ObjectsContact, Account (add both)
e
In the Prompt Template Body — type this exact prompt (use the merge field picker for {!} fields):
You are a professional sales representative at XYZ Company — a pharma-grade silicone and polymer manufacturer. Write a professional, warm, and concise follow-up email (under 150 words) to: Contact: {!$Input:Contact.FirstName} {!$Input:Contact.LastName} Title: {!$Input:Contact.Title} Company: {!$Input:Account.Name} Industry: {!$Input:Account.Industry} Regarding Opportunity: Deal Name: {!$Input:Opportunity.Name} Current Stage: {!$Input:Opportunity.StageName} Deal Value: {!$Input:Opportunity.Amount} Expected Close Date: {!$Input:Opportunity.CloseDate} Probability: {!$Input:Opportunity.Probability}% INSTRUCTIONS FOR THE EMAIL: - Start with a warm, personalized greeting using the contact's first name - Reference the specific opportunity/deal naturally - Mention the current stage and express positive momentum - Include a clear call-to-action (schedule a call, confirm terms, etc.) - Keep tone: professional but friendly — not overly formal - Sign off as "XYZ Company Sales Team" - Do NOT include any pricing unless it's from the data above - Do NOT make commitments like "guaranteed delivery" or "best price" Write only the email — no explanation or preamble.
Setup → Prompt Builder → New Prompt Template → Sales Email → Fill details → Paste prompt → Save
📸 What You Should See — Prompt Builder Editor
A split-screen editor: Left side = Prompt Template Body (where you type the prompt). Right side = Preview panel where you can test with real records.

The merge field picker (usually a button like "Insert Merge Field" or a {!} button) lets you browse and insert fields from related objects without typing them manually.

After pasting the prompt, click Save — then Activate to make it usable.
f
Click Save → Then click Activate
✅ Template 1 Saved and Active!
"XYZ Follow-up Email" template is now active. In the next steps, we'll test it with real data and then connect it to the XYZ Sales Assistant agent as an Action in Module 7.
2
Test the Email Template with Real Data
Generate your first AI email using MedTech Opportunity data
a
In Prompt Builder, open "XYZ Follow-up Email" template
b
Look for "Preview" or "Generate Preview" button
c
Select a record to test with — search for "MedTech Device Seals Annual Contract" (the Opportunity we created in Module 3)
d
Click "Generate" or "Preview"
e
Watch the AI generate a real email using real data! 🎉
Prompt Builder → XYZ Follow-up Email → Preview → Select Opportunity → Generate
📧 Expected AI-Generated Email Output:
🎉 Your First AI-Generated Grounded Email!
Notice how the AI used ALL the merge field data: Priya's name, MedTech Solutions, the deal name, stage, amount in ₹, and close date — all automatically pulled from your Salesforce records. This email took 3 seconds to generate and is more personalized than most reps write manually!
3
Build Template 2 — Account Summary
Quick AI briefing on any Account — for pre-meeting prep
a
Prompt Builder → New Prompt Template → Select "Record Summary"
b
Fill template details:
FieldValue
Template NameXYZ Account Summary
Primary ObjectAccount
DescriptionGenerates a concise Account briefing for pre-meeting preparation
c
Paste this prompt in the template body:
You are an AI assistant for XYZ Company's sales team. Create a concise account briefing for an upcoming customer meeting with: Company: {!$Input:Account.Name} Industry: {!$Input:Account.Industry} Location: {!$Input:Account.BillingCity}, {!$Input:Account.BillingCountry} Phone: {!$Input:Account.Phone} Annual Revenue: {!$Input:Account.AnnualRevenue} Number of Employees: {!$Input:Account.NumberOfEmployees} Account Type: {!$Input:Account.Type} Description: {!$Input:Account.Description} Write a structured briefing with these sections: 1. COMPANY OVERVIEW (2-3 sentences about who they are) 2. RELATIONSHIP STATUS (Customer/Prospect and key notes) 3. BUSINESS POTENTIAL (based on industry, size, revenue) 4. RECOMMENDED TALKING POINTS (2-3 bullet points for the meeting) Keep it practical and under 200 words total. Write for a sales rep preparing for a meeting.
d
Click SaveActivate
e
Test with ABC Pharma Pvt Ltd account — you should see a structured meeting briefing!
📸 Expected Account Summary Output
COMPANY OVERVIEW: ABC Pharma Pvt Ltd is a leading pharmaceutical manufacturer based in Mumbai, Maharashtra with 500 employees and ₹5 Cr annual revenue operating in the Healthcare industry...

RELATIONSHIP STATUS: Existing Customer since 2019. Key customer for XYZ's pharma-grade silicone products...

RECOMMENDED TALKING POINTS: • Discuss renewal of Gasket Supply contract • Explore new silicone tubing requirements for production line upgrade • Introduce new pharma-grade product catalog...
4
Build Template 3 — Next Steps Generator
Auto-generate Opportunity Next Steps field using AI
a
Prompt Builder → New Prompt Template → Select "Field Generation"
b
Fill template details:
FieldValue
Template NameXYZ Next Steps Generator
Primary ObjectOpportunity
Target FieldNext Step (Opportunity.NextStep)
DescriptionAI suggests the best next action for an opportunity based on its current stage
c
Paste this prompt:
Based on this opportunity's details, suggest the single most important next action for the sales rep. Opportunity: {!$Input:Opportunity.Name} Account: {!$Input:Account.Name} Stage: {!$Input:Opportunity.StageName} Amount: {!$Input:Opportunity.Amount} Close Date: {!$Input:Opportunity.CloseDate} Probability: {!$Input:Opportunity.Probability}% Current Next Step: {!$Input:Opportunity.NextStep} Based on the stage and probability: - Qualification (10-30%): Focus on discovery and requirements - Proposal/Price Quote (40-60%): Focus on proposal delivery and questions - Negotiation/Review (70-85%): Focus on finalizing terms and removing blockers - Closed Won (100%): Focus on onboarding and delivery Write ONLY the next step in ONE sentence (max 15 words). Example: "Send revised pricing proposal by Friday and schedule review call"
d
Click SaveActivate
e
Test with the BioLife Research opportunity — should return something like: "Schedule discovery call to understand lab testing requirements by next week"
✅ All 3 Templates Built!
You now have 3 active Prompt Templates:
1. XYZ Follow-up Email — Generates professional follow-up emails
2. XYZ Account Summary — Creates meeting briefings
3. XYZ Next Steps Generator — Suggests next actions per opportunity stage
🔗

4. Connecting Prompt Templates to Your Agent

How your Sales Assistant uses these templates as Actions

Prompt Templates connect to Agentforce agents as Prompt Template Actions. When a sales rep asks "Draft a follow-up email for Priya at MedTech" — the agent calls the "XYZ Follow-up Email" Prompt Template Action, which fetches the Opportunity data, populates the merge fields, sends to LLM, and returns the generated email. We connect this in Module 7.
Prompt TemplateAgent TopicWhen Agent Uses ItConnected In
XYZ Follow-up EmailSales AssistantUser asks "draft email to [contact]" or "follow up on [deal]"Module 7
XYZ Account SummarySales AssistantUser asks "brief me on [account]" or "prep for my meeting with [company]"Module 7
XYZ Next Steps GeneratorSales AssistantUser asks "what should I do next for [opportunity]?"Module 7
⚡ Preview: What This Looks Like in the Agent
Sales rep: "Draft a follow-up email for the MedTech deal"

Agent thinking: "User wants email draft → call XYZ Follow-up Email Prompt Template → fetch MedTech Opportunity + Priya contact → generate email → return to user"

Agent response: "Here's a draft follow-up email for Priya Sharma at MedTech Solutions: [full professional email]"

Sales rep: copies, reviews, sends. Done in 10 seconds.
🧠

5. Prompt Engineering Tips for Salesforce Templates

Write better prompts — get dramatically better AI outputs

TechniqueExampleWhy It Works
Role assignment"You are a professional sales rep at XYZ Company..."Sets AI's persona — responses match the role's expertise and tone
Explicit format rules"Write in 4 sections: Overview, Status, Potential, Talking Points"AI follows structured output — consistent, scannable results every time
Word/length limits"Under 150 words", "ONE sentence", "max 3 bullet points"Prevents verbose AI responses that overwhelm users
Negative instructions"Do NOT make delivery commitments. Do NOT include pricing not in the data."Prevents hallucinations and policy-violating content
Conditional logic"If Stage = Qualification, focus on discovery questions. If Negotiation, focus on terms."AI adapts output based on record state — context-aware responses
Output-only instruction"Write only the email — no explanation or preamble."Prevents AI from adding meta-commentary like "Here is your email:"
Few-shot examples"Example output: 'Send proposal by Friday and confirm receipt with Priya'"Shows AI exactly what good output looks like — dramatically improves quality
🎯 The Most Common Prompt Template Mistake
Not testing with real data. Prompt templates look great in isolation but fail badly when real record data is sparse, formatted differently, or missing fields. Always test your template with at least 3 different real records — including edge cases like missing amounts, null fields, or non-standard stage names.
🔧

6. Troubleshooting Prompt Builder Issues

Common problems and exact fixes

ProblemRoot CauseFix
Merge field shows as blank in outputField is empty on the test record, OR merge field path is wrongCheck the actual record has data in that field. Verify merge field path: {!$Input:Object.FieldAPIName}
"Prompt Builder" not found in SetupEinstein Generative AI not enabled, or missing permissionEnable Einstein Generative AI → Add "Prompt Template User" Permission Set → Refresh
Generated email is too genericPrompt doesn't have enough specific instructions or merge fieldsAdd more merge fields (Stage, Amount, Close Date) and add "refer to the specific opportunity details" instruction
AI generates wrong formatFormat instruction too vagueGive a concrete example in the prompt: "Format as: Subject line / Greeting / Body (2 paragraphs) / CTA / Sign-off"
Template activates but doesn't appear in agentTemplate not yet connected as ActionThis is expected! Connection happens in Module 7. Template is ready — agent connection is next step.
Preview shows error "Unable to generate"LLM token limit exceeded (prompt too long)Shorten prompt. Remove redundant instructions. Keep total prompt under 2000 characters for best results.
🎯

7. Prompt Builder — Interview Questions & Answers

Common questions in Agentforce developer interviews

Interview QuestionBest Answer
What is Prompt Builder in Salesforce?A no-code tool for creating reusable AI prompt templates grounded in Salesforce record data. Three types: Field Generation (auto-fill fields), Record Summary (summarize records), Sales Email (draft emails). Templates use merge fields to inject real Salesforce data into AI prompts.
What is grounding in the context of Agentforce?Grounding = anchoring AI responses in real, factual Salesforce data. Merge fields pull actual record values into the prompt before sending to LLM. Without grounding, AI generates generic, potentially hallucinated responses. With grounding, responses are accurate and contextual.
What are merge fields in Prompt Builder?Placeholders like {!$Input:Contact.FirstName} that get replaced with real Salesforce field values before the prompt is sent to the AI. They "ground" the AI in actual CRM data — ensuring every generated email uses the real contact's name, real deal amount, real stage.
How does a Prompt Template connect to an Agentforce agent?As a Prompt Template Action in Agent Builder. When agent recognizes the intent (draft email, summarize record), it calls the relevant Prompt Template Action, which fetches record data, populates merge fields, calls LLM, and returns generated output to the user.
What is the difference between the 3 Prompt Template types?Field Generation: AI generates a single field value. Record Summary: AI summarizes an entire record into readable paragraphs. Sales Email: AI drafts a complete email grounded in opportunity/account/contact data. Each type is optimized for its specific output format.

Module 6 Summary

3 AI templates built — ready to connect to your agent

  • Prompt Builder — reusable AI prompt templates grounded in real Salesforce data via merge fields
  • 3 Template Types — Field Generation, Record Summary, Sales Email — each for different output needs
  • Merge Fields — {!$Input:Object.Field} pulls real Salesforce data into prompts before LLM sees them
  • Grounding — anchoring AI in factual record data = accurate, personalized responses vs generic hallucinations
  • Template 1 — XYZ Follow-up Email: generates professional emails from Opportunity + Contact data
  • Template 2 — XYZ Account Summary: creates pre-meeting briefings from Account data
  • Template 3 — XYZ Next Steps Generator: suggests next actions based on Opportunity stage
  • 7 Prompt Engineering Tips — role assignment, format rules, word limits, negative instructions, conditional logic
🎯 Where You Are — Course Checkpoint
You've now built: ✅ Developer Org ✅ Agent with 3 Topics ✅ Production Instructions ✅ 3 AI Prompt Templates

Starting Module 7, your agent gets REAL DATA superpowers. Standard Actions (M7) connect to Salesforce data out of the box. By Module 9 (Apex Actions), your agent will actually fetch live Opportunities and Accounts and show them in conversations. The agent becomes truly powerful!
🧠 Module 6 — Knowledge Check
Q1: What is grounding in Prompt Builder and why does it matter? → Grounding = injecting real Salesforce data via merge fields before sending to LLM. Without it: generic hallucinations. With it: accurate, personalized responses using actual record data.
Q2: What is the merge field syntax in Prompt Builder? → {!$Input:ObjectName.FieldAPIName} — e.g., {!$Input:Contact.FirstName}, {!$Input:Opportunity.Amount}
Q3: When would you use "Field Generation" vs "Sales Email" template type? → Field Generation: auto-populate a single Salesforce field. Sales Email: generate a complete email draft. Field Generation = one field. Sales Email = full email content.
Q4: How does a Prompt Template connect to an Agentforce agent? → As a Prompt Template Action in Agent Builder (Module 7). Agent recognizes email draft intent → calls template → fetches data → LLM generates → returns to user.
Q5: Your AI email template generates emails that are too long and verbose. How do you fix it? → Add explicit word limit in prompt: "Write under 150 words" + "Be concise — sales reps need quick reads" + remove any instructions that encourage elaboration.

🚀 Ready for Module 7?

Next: Standard Actions — Connect your agent to real Salesforce data using pre-built Standard Actions. No code needed! Your agent will finally be able to search records, retrieve account info, and use your Prompt Templates — all in live conversations.

Module 7: Standard Actions →