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!
Part 1: Prompt Builder Fundamentals
What is a prompt template? 4 template types. When to use each.
| Template Type | Purpose | When to Use | Example Output |
|---|---|---|---|
| Field Generation | Generate or fill a single field value using AI | Auto-fill email subject, lead source, next step field | Generate email subject from Account name & Opportunity stage |
| Record Summary | Create a summary of a single record | Summarize Account for sales rep, brief case overview | “ABC Pharma: Healthcare, Mumbai-based, $50M revenue, key contact Rajesh...” |
| Sales Email | Generate customized email to customer | Draft follow-up emails, outreach, objection handling | Professional email to Rajesh at ABC Pharma w/ personalized details |
| Custom (Unrestricted) | Any AI task using Salesforce data | Competitive analysis, deal strategy, risk assessment | BI-generated risk analysis for Opportunity based on stage, days open, etc. |
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.
Part 2: Grounding — The Secret Sauce
Add Salesforce data context to prompts. Why it matters. How it works.
AI generates: “Dear ABC Pharma, we offer silicone solutions for various industries...” (generic, no context)
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 Method | How It Works | When to Use | Example |
|---|---|---|---|
| Record Context | Template 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 Table | Pass multiple records as a table inside prompt. AI processes table of data. | Compare multiple opportunities, analyze account portfolio, summarize competitor list | Table of top 5 open Opps w/ stage, amount, days open — AI analyzes & prioritizes |
| Free-Form Input | User (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. |
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!
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
Part 3: Invoking Prompts from Your Agent
Call prompt templates from Subagents. Invoke from Standard Actions, Flows, Apex.
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!
Part 4: Prompt Template Best Practices
How to write world-class templates. Avoid common mistakes.
| Rule | What It Means | Good Example | Bad Example |
|---|---|---|---|
| 1. Be Specific | Tell 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 Context | Give AI the data it needs (grounding!) | Include {{Account.Industry}}, {{Opportunity.Stage}}, {{Account.AnnualRevenue}} in prompt | No field variables — make AI guess |
| 3. Set Constraints | Word limit, format, tone | “150-200 words. Professional tone. Bullet points for readability.” | No limits. AI rambles. |
| 4. Include Examples | Show AI what good output looks like (few-shot) | Include 1 sample summary showing desired structure & depth | Expect AI to guess what format you want |
| 5. Test Thoroughly | Use Test feature. Try with different records | Test with ABC Pharma, MedTech, BioLife. Verify quality is consistent | Create template once, never test, deploy broken |
Examples:
— Account_Summary_ForSales
— Opportunity_RiskAnalysis_ForManager
— Contact_Email_InitialOutreach
— Case_NextSteps_ForSupport
Prompt Builder — Interview Questions
Real questions from Agentforce developer interviews
| Interview Question | Best 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 matters | Grounding = 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 methods | 1. 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.
🚀 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 —
New interview questions every week
Follow for fresh Salesforce Q&A, free courses, and real interview experiences — straight from the trenches.
Follow Us ↗1,500+ free questions, kept free thanks to readers like you.
Help Us Keep This Free →Free Salesforce interview prep, structured courses and practice quizzes. Built by a working Salesforce developer — no paywalls, no signup.