Craft an Effective Prompt Template
Learning Objectives
After completing this unit, you’ll be able to:
- Describe the role of prompts and prompt templates.
- List the different prompt template types.
- Integrate Salesforce org data into prompt templates to enhance AI-generated responses.
The Power of Prompts in Everyday Life
You might not realize it, but you’ve been using prompts your entire life. Every time you give an instruction expecting a specific response, you’re engaging in prompt engineering.
- When you type a message into a chatbot for customer support.
- When you tell your voice assistant to set a reminder.
- When you ask a cashier for change in smaller bills.
- Even when ordering a coffee and specifying, “a large iced latte with oat milk, no sugar,” you’re providing detailed input for a desired outcome.
These everyday interactions demonstrate how structured input leads to clear, expected results. And that’s just like prompt engineering in AI.
Now, let’s explore how this concept applies in a real-world customer service scenario.
Handling Guest Complaints at Coral Cloud Resorts
Sofia Rodriguez and her family eagerly anticipated their Coral Cloud Resorts vacation, especially the White Water Rafting Rush Experience. However, when the activity was unexpectedly canceled, she reached out to customer support.
As Coral Cloud Resorts grows in popularity, guest complaints like Sofia’s are becoming more common, overwhelming the customer service team and leading to longer response times. To provide faster resolutions and improve guest satisfaction, the resort wants to implement Agentforce for Service to streamline complaint handling and enhance the guest experience. Becca, an admin at Coral Cloud Resorts, has been tasked with setting up the agent. She starts by outlining how Agentforce automation can help.
Automate Case Resolutions with Agentforce
By using Agentforce to automate responses and resolutions, Coral Cloud Resorts can address issues quickly and efficiently while improving guest satisfaction. Here’s a high-level look at how this process can work.
Simple Workflow for Guest Complaints
-
Guest submits a complaint: The guest uses the agent in a chat to voice their complaint.
-
Agent verifies guest’s identity: The system checks the guest’s identity and any open case details.
-
Agent categorizes the complaint: Based on the nature of the complaint, the agent classifies the issue into one of four tiers.
- Tier 0 (Minor Preference): Small disruption based on guest preference.
- Tier 1 (Minor Inconvenience): Small disruptions like a delayed start time for an activity.
- Tier 2 (Moderate Disruption): Booking errors or service dissatisfaction.
- Tier 3 (Major Disruption): Activity cancellations or severe guest impact.
- Tier 0 (Minor Preference): Small disruption based on guest preference.
-
Agent offers a resolution: The agent provides a resolution based on the case details and the compensation tier.
-
Guest selects compensation: The guest chooses their preferred resolution option.
-
Case closed: Once the guest selects an option, the agent finalizes and closes the case.
While agents are powerful on their own, they still rely on clear, well-structured prompts to deliver accurate, consistent, and helpful responses. A prompt template acts like a guide: It ensures the agent has the right context, tone, and data to handle each situation effectively. This is especially important when dealing with sensitive issues like guest complaints, where personalized and precise communication matters. By using a prompt template, you can help an agent generate better outputs and maintain a consistent voice across all guest interactions.
Next, explore the template types and learn how Becca sets up a prompt template for Coral Cloud Resorts so she can connect it to an agent later on.
Select the Right Prompt Template
Prompt Builder gives you different prompt templates to choose from for your use case.
-
Field Generation templates work well when you want to use one object to populate information into a record field in Lightning Experience.
-
Flex templates offer the most versatility, allowing you to use multiple objects, free text input fields (these are a non-record type of input field consisting solely of text), and data models for richer responses.
-
Standard templates are ideal for specific use case-related responses but are restricted to that scope–for example, specifically for work summaries, sales pitch coaching, or ground service replies.
Why Choose a Flex Template for This Use Case?
Guest complaints can range from simple inconveniences to more complex issues, so Becca needs a solution that can adapt. Flex templates are ideal for this scenario because they remove many of the restrictions found in more narrowly defined templates. They allow for:
- The use of multiple objects.
- Free text inputs for tailored customization.
- Data models that generate dynamic, context-aware responses.
This level of flexibility makes Flex templates perfect for interactive chat experiences, personalized recommendations, and context-rich insights—where adaptability is essential.
At Coral Cloud Resorts, every guest is treated with care. And when something goes wrong, Coral Cloud wants to make it right. That’s why the resort wants to build an agent that listens when a guest has a complaint, retrieves their case details, and recommends the appropriate compensation to help turn the experience around.
To make this process even more efficient and personalized, Becca builds a Flex prompt template. With it, the agent can dynamically tailor its responses based on each guest’s unique situation—ensuring the agent delivers the right solution every time.
Sign Up for a Free Developer Edition Org with Prompt Builder and Agentforce
To complete this module, you need a special Developer Edition org that contains Prompt Builder and Agentforce and our sample data. Get this free Developer Edition and connect it to Trailhead now so you can complete the challenges in this module. Note that this Developer Edition is designed to work with the challenges in this badge, and may not work for other badges. Always check that you’re using the Trailhead Playground or special Developer Edition org that we recommend.
- Sign up for this free Developer Edition org with Prompt Builder and Agentforce.
- Fill out the form:
- For Email, enter an active email address.
- For Username, enter a username that looks like an email address and is unique, but it doesn't need to be a valid email account (for example, yourname@example.com).
- For Email, enter an active email address.
- After you fill out the form, click Sign me up. A confirmation message appears.
- When you receive the activation email (this might take a few minutes), open it and click Verify Account.
- Complete your registration by setting your password and challenge question. Tip: Save your username, password, and login URL in a secure place—such as a password manager—for easy access later.
- You are logged in to your Developer Edition.
Now connect your new Developer Edition org to Trailhead.
- Make sure you're logged in to your Trailhead account.
- In the Challenge section at the bottom of this page, click the org name and then click Connect Org.
- On the login screen, enter the username and password for the Developer Edition you just set up.
- On the Allow Access? screen, click Allow.
- On the Want to connect this org for hands-on challenges? screen, click Yes! Save it. You are redirected back to the challenge page and ready to use your new Developer Edition to earn this badge.
Create a Flex Prompt Template
Now that Becca’s selected the Flex template, let’s see how she sets it up in Prompt Builder. If you like, follow along in your new Developer Edition org.
- Click
and select Setup. The Setup page opens in a new tab.
- In the Quick Find box, search for and select Einstein Setup.
-
Turn on Einstein by clicking the toggle.
- Refresh your browser window to reveal new admin settings now that Einstein is enabled.
- In the Quick Find box, search for and select Prompt Builder.
- Click New Prompt Template.
- Fill in these fields:
- Prompt Template Type: Flex
- Prompt Template Name:
Guest Experience Compensation
- API Name:
Guest_Experience_Compensation
- Template Description:
This template generates personalized compensation recommendations based on guest feedback and open case details, with tailored and empathetic responses.
- Prompt Template Type: Flex
- For Flex templates, you can add up to five resources. Under Define Sources, add two resources. The first is the object type:
- Name:
Contact
- API Name:
Contact
- Source Type: Object
- Object:
Contact
- Name:
- Click Add Resources and add the second free text resource:
- Name:
Complaint
- API Name:
Complaint
- Source Type:
Free Text
- Name:
- Click Next. The Prompt Template Workspace opens.
The workspace is ready!
Draft the Prompt
Now that her Prompt Template Workspace is set up, it’s time for Becca to build the actual prompt.
She enters the following text into the Prompt Template Workspace:
You’re a customer service representative responding to [Guest Name], a guest at Coral Cloud Resort, regarding a complaint they submitted about a recent experience they booked. Determine the appropriate tier of compensation based on the guidelines below: """[Tiered Guest Compensation]""" Response Format: “Hi [Guest Name], We know this wasn’t the experience you were expecting, and we want to make it right. [If Tier 0] We've noted your preferences for future stays and invite you to share any additional feedback to help us improve. [If Tier 1-3] Based on your recent experience, we’d like to offer you one of the following options: [Insert compensation options based on the determined tier] Please let us know which option you’d like to select, and we’ll take care of the rest. If you need any further assistance, we’re here to help!” Now create a message.
Refine the Prompt for Personalization
At this stage, the prompt structure is in place, but it’s still too generic. If you provide a large language model (LLM) with a general prompt, you get a general response. Without detailed input, the LLM lacks important context—it won’t recognize the guest’s name, your business specifics, or any relevant case details.
To generate more relevant and effective responses, Becca needs to add precision and personalization to the prompt. Let’s explore how she does that.
Add Merge Fields
By incorporating merge fields and structured data, Becca can make the prompt dynamic and tailored to each guest.
It takes just a few steps to personalize the agent’s response with a merge field.
- In the Prompt section, find the text
[Guest Name]
in the instructions.
- Delete the
[Guest Name]
placeholder and replace it with a merge field.- Click Insert Resource and select Contact > FirstName.
- Click Insert Resource and select Contact > FirstName.
Add More Context
Coral Cloud Resorts follows a tiered guest compensation structure that categorizes guest service disruptions into four levels: Minor Preference, Minor Inconvenience, Moderate Disruption, and Major Disruption. This structured approach ensures fair and consistent compensation based on the severity of the guest’s complaint.
Here’s how Becca clearly defines these tiers and their compensation structure to help the agent generate accurate and appropriate responses that align with Coral Cloud Resort’s business policies.
- Find
[Tiered Guest Compensation]
in the prompt .
- Replace that placeholder with the following structured details:
```Tier 0 (Minor Preference Issue) - No Open Cases Trigger: There are no open cases. Action: Apologize and acknowledge the feedback. Inform the guest that preferences will be noted for future stays and invite them to share more feedback to help improve. Do not offer compensation options. Tier 1 (Minor Inconvenience) Trigger: Issues such as delayed activity start times, minor room maintenance problems, or slow restaurant service fall into this category. Compensation Options: $50 Resort credit Complimentary drink, appetizer, or dessert Early check-in / late checkout (if available) Tier 2 (Moderate Disruption) Trigger: Covers booking errors affecting reservations, room/service dissatisfaction, extended delays Compensation Options: Rebooking of the same or alternative experience Resort credit (Up to $350 for dining, spa, or activities) Complimentary room upgrade (if available) Tier 3 (Major Disruption) Trigger: Activity cancellations, major booking failures, severe service issues, safety concerns Compensation Options: Resort credit (Up to $1000) Complimentary premium experience (private tour, fine dining, spa treatment) Complimentary 1-night stay extension```
And here’s what her completed prompt template should look like.
You’re a customer service representative responding to {!$Input:Contact.Name}, a guest at Coral Cloud Resort, regarding a complaint they submitted about a recent experience they booked. Determine the appropriate tier of compensation based on the guidelines below: ```Tier 0 (Minor Preference Issue) - Complaints that don’t significantly impact their experience but still warrant acknowledgment. Include a personalized apology message acknowledging the feedback. Inform the guest that a note will be added to their profile to accommodate preferences for future stays. End with a friendly message inviting the guest to share more feedback for continuous improvement. Tier 1 (Minor Inconvenience) Issues such as delayed activity start times, minor room maintenance problems, or slow restaurant service fall into this category. Compensation Options: $50 Resort credit Complimentary drink, appetizer, or dessert Early check-in / late checkout (if available) Tier 2 (Moderate Disruption) Covers booking errors affecting reservations, room/service dissatisfaction, extended delays Compensation Options: Rebooking of the same or alternative experience Resort credit (Up to $350 for dining, spa, or activities) Complimentary room upgrade (if available) Tier 3 (Major Disruption) Activity cancellations, major booking failures, severe service issues, safety concerns Compensation Options: Resort credit (Up to $1000) Complimentary premium experience (private tour, fine dining, spa treatment) Complimentary 1-night stay extension``` Response Format: “Hi [Guest Name], We know this wasn’t the experience you were expecting, and we want to make it right. Based on your recent experience, we’d like to offer you one of the following options: [If Tier 0] We've noted your preferences for future stays and invite you to share any additional feedback to help us improve. [If Tier 1-3] Based on your recent experience, we’d like to offer you one of the following options: [Insert relevant compensation option] Please let us know which option you’d like to select, and we’ll take care of the rest. If you need any further assistance, we’re here to help!” Now create a message.
Test and Preview Your Prompt Template
Once Becca has crafted her prompt template instructions, it’s time to test them to make sure they deliver the results she expects. The first step: choosing which LLM should power her template.
Prompt Builder gives you access to multiple LLMs, and Becca wants to pick the right tool–or LLM–for the job. Need fast responses? Detailed analysis? Structured output like JSON? Different models are optimized for different needs.
Here are a few factors to consider.
-
Speed vs. complexity: Some models prioritize speed, while others are built for deep reasoning.
-
Structured vs. natural output: Choose a model that fits your format—whether that’s structured data or conversational text.
Start with a general-purpose model like Omni, then experiment with others. If you’re looking for quicker replies, try a turbo model. If your prompt requires deeper analysis, explore more advanced options.
By testing your template with real data, you can confirm it pulls in the right context, responds with accuracy, and sounds personalized. Adding details and a thoughtful tone helps your agent sound human while keeping responses consistent and on brand.
This is the power of Prompt Builder: It brings together Salesforce data, clear prompt instructions, and the right LLM to deliver tailored, reliable responses at scale.
Becca dives in and puts her prompt to the test. Here’s how.
- In Template Settings under Model, select OpenAI GPT 4 Omni Mini.
- In Preview Settings under Inputs, in the Contact text box, search for and select Sofia Rodriguez. In the Complaint text box, type,
The music was too loud on the beach.
- Click Save & Preview.
Review the Generated Response section to see how the prompt template affects the test response. If the response isn’t quite right, don’t worry, you can revise the template, test again, and keep iterating until it meets your needs. Feel free to change the Language to review the response in various languages.
- Click Activate.
Let’s Recap
You’re now equipped with the foundational skills to create and refine AI-powered prompts! From crafting structured instructions to selecting the best template type, you’ve followed along with Becca and learned how to optimize responses for your business needs. Once you create a prompt template, you can reuse it anywhere. Whether you’re working in sales, service, or any other part of your business, your well-designed prompt template ensures consistent and high-quality AI-generated responses.
In the next unit, learn how Becca connects her prompt to an agent, so her automation is not only smart, but actionable. This step is where the magic happens: Your prompt meets your agent, and your workflow comes to life!
Resources