Course Content
AI Agents
Understand how intelligent agents operate within the Agentforce ecosystem, from autonomous decision-making to task execution and communication within distributed systems.
0/6
Prompt Engineering
Learn the art and science of crafting effective prompts for AI agents to maximize accuracy, reliability, and contextual relevance. Perfect for developers, analysts, and AI integrators.
0/6
Data 360 for Agentforce
Explore the data architecture and services that power Agentforce. Learn how to securely manage, query, and optimize data workflows for agent interactions and training.
0/4
Development Lifecycle
Master the lifecycle of Agentforce solution development—from ideation and design to deployment and optimization. We'll cover versioning, collaboration, and testing best practices.
0/3
Multi-Agent Interoperability
Delve into how different AI agents collaborate across systems and services, ensuring seamless task handoffs, data sharing, and coordination in complex workflows.
0/3
Final Exam Preparation
This walkthrough focuses on how Salesforce expects Agentforce to behave. You’ll learn the “exam traps” that cause wrong answers—even when you know the features.
0/3
Agentforce Specialist Certification (Study Guide)

Prompt Engineering

 Prompt Builder 

Learn how Prompt Builder creates reusable prompt templates, which template type to choose, and how to connect templates to flows and automation.

Table of Contents
  • Learning Outcomes
  • Prompt Builder Overview
  • Prompt vs Prompt Template (and Grounding)
  • Prompt Template Workspace (Draft + Preview)
  • Prompt Template Types (Quick Guide)
  • How Templates Are Used (Email, Fields, Summaries, APIs)
  • Prompt Templates + Flows (Two Key Methods)
  • Scenarios & Solutions (Exam-style)

After this lesson, you can…
  • Describe how to use Prompt Builder to create prompt templates for AI-generated responses.
  • Identify prompt template types available in Prompt Builder.
  • Explain how templates are used and key considerations when invoking them with flows.
  • Choose the right Prompt Builder approach to meet a business requirement.

Introduction

Prompt Builder lets you create reusable prompt templates that instruct large language models (LLMs) to generate consistent, high-quality responses. Templates are designed to be repeatable, testable, and grounded in Salesforce data using merge fields.

You’ll see Prompt Builder used for common outcomes like drafting sales emails, generating text for record fields, summarizing records, and powering custom experiences through flows and invocable actions.

When Prompt Builder is appropriate: whenever a business wants repeatable AI output with clear instructions, consistent tone, and grounded data.

Step 1: Prompt vs Prompt Template (and Grounding)

Prompt
Detailed instructions to the LLM

A prompt is the instruction set you send to the model. Output quality depends heavily on design: clarity, constraints, and guidance.

Prompt Template
Reusable prompt built for a use case

A prompt template is a managed, reusable version of a prompt—built for a specific business outcome and often grounded with data.

Grounding (Non-negotiable for quality)

Grounding adds relevant data (like record fields, knowledge, or interaction context) so the response is personalized and accurate. In Prompt Builder, grounding is commonly done using merge fields/resources.

Step 2: Prompt Template Workspace (Draft → Preview)

The Prompt Template Workspace is where you draft the prompt, add merge fields/resources for grounding, and test results before publishing.

Draft

  • Write clear instructions (goal, constraints, tone)
  • Add guidelines (format, length, style)
  • Ground with merge fields/resources

Preview

  • Resolution: shows resolved prompt + grounded data
  • Response: shows the generated output
  • Test with real records (Save & Preview)
Tip: When you test, check both the resolved prompt and the output. If the resolution is missing key data, fix grounding first.

Step 3: Access & Permissions (Who can build vs run)

Prompt Builder access depends on enabling Einstein Generative AI and assigning permission sets that match the user’s responsibilities.

Prompt Template Manager

Create and manage prompt templates in Prompt Builder (builders/admins).

Prompt Template User

Access and run prompt templates (end users).

Step 4: Prompt Template Types (Choose by Outcome)

The fastest way to choose the right template type is to ask: Where will the output appear? (email composer, record field, summary panel, custom UI, service replies, etc.)

🧩 Field Generation

Generates content for a record field in Lightning. Users click an icon next to a dynamic form field to populate it.

Best for: editable AI text in-page (human-in-the-loop).

✉️ Sales Email

Generates personalized sales emails grounded in record data. Used from the email composer via Draft with Einstein.

Best for: email drafts with consistent tone + personalization.

📝 Record Summary

Summarizes record data for a quick, comprehensive view. Often used by summary actions (including agent summaries).

Best for: consistent summaries across users/teams.

⚙️ Flex

A “do anything” template for unique business use cases not covered by other types. Define resources and inputs.

Best for: proposals, multi-object outputs, custom experiences.

💬 Service Replies (Contextual / Grounded)

Tailors customer support replies for live chat/messaging—either context-aware or grounded in knowledge/case history.

Best for: support messaging with brand voice + policy grounding.

📚 Knowledge Answers

Customizes how answers are generated from Knowledge (tone, included info, formatting).

Best for: consistent knowledge-based answers at scale.

Step 5: How Prompt Templates Are Used

How you run a template depends on the template type and where you need the output.

In the UI

  • Sales Email: Draft with Einstein in email composer
  • Field Generation: icon next to a dynamic form field
  • Record Summary: summary views/actions

In automation / integration

  • Flow: Prompt Template flow action
  • Invocable action: call from workflows
  • API/Apex: Connect REST API or Connect in Apex

Step 6: Prompt Templates + Flows (Two Methods)

Flows can either invoke a prompt template or feed dynamic instructions/data into a template.

Method A: Prompt Template Flow Action

Add the Prompt Template action to a flow to generate a response using a selected template and inputs. (Template must have an active version.)

Method B: Template-Triggered Prompt Flow

Use a template-triggered prompt flow to run logic and send “prompt instructions” into the template via a flow merge field. Great when you need dynamic data shaping before generation.

Flow decision tip: If users input data and you generate output → use the Prompt Template flow action. If you need the template to pull/run logic first → use a template-triggered prompt flow.

Scenarios & Solutions

Practice: Match the Requirement to Prompt Builder

These scenarios mirror how questions are written: identify the right template type and how it should be invoked.

Scenario: Unique business output (proposal-style)

A team needs an output that isn’t covered by standard template types—like generating a structured sales proposal using data from multiple objects.

Solution: Use a Flex prompt template. Add resources for the required objects and invoke it via an invocable action, Flow, API, or Apex depending on where the proposal is needed.

Scenario 3: Personalized summaries on a contact record page

A hotel wants personalized guest summaries (interests and activity preferences) accessible on the contact record page only.

Solution: Create a Field Generation prompt template. Ground it with contact fields, then let users run it from the icon next to the dynamic form field on the contact page.

Scenario 4: Custom UX—user enters order number, sees summary

Users enter a sales order number and Salesforce should generate and display an order summary using a predefined prompt template.

Solution: Build a Screen Flow to collect the order number, then use the Prompt Template flow action to invoke the template and display the generated summary on a screen element.

Scenario 5: Human-in-the-loop editable descriptions

Leadership wants a dynamic form field auto-populated by AI, but easy for users to review and edit before finalizing (oversight + validation).

Solution: Use a Field Generation prompt template so the output lands directly in a field users can edit before saving—perfect for a human-in-the-loop process.

Scenario 6: Personalized marketing emails

A company wants marketing emails that highlight products aligned to each customer’s interests and preferences.

Solution: Create a custom Sales Email prompt template grounded in customer preferences and product interest data. Users generate drafts via Draft with Einstein in the email composer.

Next: Build Your First Template (Guided Lab)

Next, you’ll create one template end-to-end: choose the type, add grounding, test in Preview, and connect it to a flow or UI entry point.

Click “Next” to Continue →
0% Complete