Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Review, Revise, and Save Prompt Templates

Learning Objectives

After completing this unit, you’ll be able to:

  • Recall how to increase accuracy and limit toxicity in a prompt response.
  • Discuss how to review and revise a prompt response.

Preview Your Prompt

After Linda drafts her Flex prompt template, it’s time to test. The Prompt Template Workspace consists of three sections. The top half is all about creating your prompt template, adding resources, and instructions. The right side displays the Template Properties, which includes the Einstein Studio workspace and the model selected in Einstein Studio.

When you use a Flex prompt template and define three or more inputs for it, you'll see an additional tab called Test Records in the Configuration panel.

Flex inputs for Account, Asset, and Contact info are displayed in the Test Records tab within the Configuration side panel.

At the bottom of the Prompt Builder Workspace, there’s a section called Preview. This section is divided into two parts.

The left side is the Resolution. It’s where your grounded prompt (the “resolved” prompt) is shown. The resolution displays how prompts and resources for the selected records are resolved based on the template. For each merge field resource, all associated CRM field values are included for the selected records. For each flow resource, Einstein displays the flow output. The right side is the Response, and it displays the generated text from the LLM.

Each time you revise your template and regenerate the preview, Einstein displays an updated prompt resolution and response. Repeat this process until you have an effective and safe prompt and response.

Preview showing the two sections.

Linda uses Preview to review the Response from the LLM. Viewing the immediate Response allows Linda to assess whether adjustments to the template are necessary.

Linda wants to test the sales email prompt template from the previous unit. Let’s see how this looks in Preview. The following is Linda’s sales email prompt from unit two.

You’re a {!$Input:Sender.Title} and your name is {!$Input:Sender.Name} from {!$Input:Sender.CompanyName}. Your prospect is {!$Input:Recipient.Name} a {!$Input:Recipient.Title}. They are based in {!$Input:Recipient.MailingCity}.

In the email, invite the prospect to attend an event for customers of Cloud Kicks new and old to network and preview upcoming products, in no more than 70 words. Explain to the prospect the possible benefits of attending the event and mention that you would be happy to chat with them further at the event or online if they need more information.

Add the following event information to the email: {!$Apex:ContactEventsPrompt.Prompt}.

Review a Generated Response

Linda can select which objects are used to test her prompt template. Linda selects the recipient record (Andy Smith - Contact) and then clicks Save & Preview. Linda can now view the “resolved” prompt template, which is the prompt after the merge fields have been replaced with the selected record data.

You’re a Salesforce admin and your name is Linda Rosenberg from Cloud Kicks. Your prospect is Andy Smith a sales manager. They are based in Toronto.

In the email, invite the prospect to attend an event for customers of Cloud Kicks new and old to network and preview upcoming products, in no more than 70 words. Explain to the prospect the possible benefits of attending the event and mention that you would be happy to chat with them further at the event or online if they need more information.

Instructions:

"""

Add the following event information to the email:

Event Name: Floating on Clouds: Toronto

Description: Cloud Kicks invites you to an unforgettable night of custom shoe magic. From innovative designs to personalized fits, this VIP event is where style meets performance.

Location: Toronto, Ontario

Time: 9/18, 2:00 PM

-

Event Name: Floating on Clouds: Houston

Description: Join us at our exclusive nationwide event where you’ll be the first to witness the hottest, limited-edition athletic kicks.

Location: Houston, Texas

Time: 7/17, 3:00 PM

-

End the email with a clear call to action to attend the event.

"""

In Linda’s test, the template returns all of the events hosted by Cloud Kicks. This is expected and shows the power of using Apex within prompt templates. The ContactEventsPrompt Apex class Linda created, returns any upcoming event hosted by Cloud Kicks. The template provides the LLM with all the information it needs to aggregate or simplify the data output.

Next, you can see that in the Response, based on the “specific” instructions in Linda’s prompt template, Einstein is able to generate an email based on Salesforce data. Nice!

Subject:

Join us at Floating on Clouds: Toronto!

Body:

Dear Andy Smith,

I hope this email finds you well. I wanted to personally reach out and extend an invitation to an exciting event near you. Cloud Kicks is hosting an exclusive VIP event called Floating on Clouds: Toronto.

At this event, you will have the opportunity to experience the magic of custom shoe designs and personalized fits. It's where style meets performance, and we guarantee it will be an unforgettable night.

Event Name: Floating on Clouds: Toronto

Date: 9/18, 2:00 PM

Location: Toronto, Ontario

We understand that you may have questions about our products and how they can enhance your athletic performance. I want to assure you that our team will be available at the event to answer any inquiries you may have.

Please mark your calendar for this exclusive event and join us on 9/18 at 2:00 PM in Toronto, Ontario. We would be thrilled to have you there!

If you have any questions or need further information, please don't hesitate to reach out to me directly. I am here to assist you.

Looking forward to seeing you at Floating on Clouds: Toronto!

Best regards,

Linda Rosenberg

Salesforce Admin

Cloud Kicks

Guard Against Toxicity

So far so good, but there’s more to discover about crafting exceptional content with generative AI. Large language models are trained on huge amounts of data. This fact puts the model at risk for producing toxic verbiage that could leak into your responses. To avoid this risk, you need to add limits and guardrails to prompt templates.

Let’s check out seven things to think about when creating guardrails to assist with response accuracy, appropriateness, and avoiding toxicity.

Considerations After Generating a Prompt Response

Topic

Description

Example Prompt Text Instructions (where applicable)

Topical Relevance

The model’s response must be grammatically correct within the ongoing conversation and directly relevant with the overall request in the prompt.

Action/Goal Completion

Assess if the response aligns with the intended action, fulfills the goal of the prompt, and satisfies the user's need by addressing everything the prompt requests.

Register/Tonal Appropriateness

When evaluating model output, consider whether the tone of voice or style is appropriate for the interaction between the response and the user. Ensure the vocabulary, punctuation, and style fit the needs of your end user.

Keep the emotion of the summary relaxed.

Factual Accuracy

When reviewing model output, watch for inaccuracies or hallucinations. Check if it correctly uses prompt data and avoids including unintended specifics.

Follow the instructions precisely, don’t add any information not provided.

Repetition

Consider the extent of variation in the response for your specific use case. Evaluate whether it meets your expectations. Consider if repetitive vocabulary is acceptable for tighter compliance. Also, decide if it’s OK if multiple responses sound the same or use the same terms.

Use clear, concise, and straightforward language using the active voice and strictly avoiding the use of filler words and phrases and redundant language.

Toxicity

Review the response for any potentially harmful content, such as offensive, disrespectful, or abusive language that could negatively impact the user experience.

Bias/Ethics

Verify that the response promotes fairness and inclusivity.

Examine the response for subtle biases in language. Ensure it doesn’t:

  • Assume gender identity based on their name alone.
  • Sideline participants with disabilities.
  • Display assumptions about race or socioeconomic status.

You must treat equally any individual or person from different socioeconomic statuses, sexual orientations, religions, races, physical appearances, nationalities, gender identities, disabilities, and ages. When you do not have sufficient information, you must choose the unknown option, rather than making assumptions based on any stereotypes.

Now that you understand what to look for when reviewing prompt templates, let’s return to the sales email prompt template and create a new version that includes the guardrails.

Saving and Versioning Prompt Templates

Prompt Builder gives users the flexibility to easily modify or version a prompt template when necessary. Navigate to the Prompt Template Workspace, select and modify your prompt template. After you do so, you can test it again by selecting a recipient or record and clicking Save & Preview in the Preview panel.

Linda is ready to update her prompt template to include guardrails. With her existing prompt template open, she clicks Save As. There are two options listed.

  • Save as a New Version: Provides access to incremental changes to the same prompt template with the same template name.
  • Save as a New Template: Creates a new prompt template with a new template and API name.

Linda is interested in creating a new version. She selects Save as a New Version.

Header is displaying name of prompt template and version 2.

In the following prompt template, the text shows the revisions that Linda added to help ensure the responses are trusted and free of bias and toxicity.

You’re a {!$Input:Sender.Title} and your name is {!$Input:Sender.Name} from {!$Input:Sender.CompanyName}. Your prospect is {!$Input:Recipient.Name}, a {!$Input:Recipient.Title}. They are based in {!$Input:Recipient.MailingCity}.

In the email, invite the prospect to attend an event for customers of Cloud Kicks new and old to network and preview upcoming products, in no more than 70 words.Explain to the prospect the possible benefits of attending the event and mention that you would be happy to chat with them further at the event or online if they need more information.

You must treat equally any individuals or persons from different socioeconomic statuses, sexual orientations, religions, races, physical appearances, nationalities, gender identities, disabilities, and ages. When you do not have sufficient information, you must choose the unknown option, rather than making assumptions based on any stereotypes.

Instructions:

"""

Follow the instructions precisely, do not add any information not provided.

Summarize in 1 sentence, and use clear, concise, and straightforward language using the active voice and strictly avoiding the use of filler words and phrases and redundant language.

Keep the emotion of the summary relaxed.

In the email, invite the prospect to attend the event in no more than 70 words.

Add the following event information to the email: {!$Apex:ContactEventsPrompt.Prompt}.

After you’ve reviewed and revised the prompt template, simply click Save and Activate and the template is ready for use.

Note

The active version of a template is the version that will be used by other features. For example, when a user drafts an email or generates record fields with Einstein, the active version of the template is what gets used.

Great work! At this point you can invite your colleagues to send those emails or use those suddenly smarter record fields. Just make sure everyone understands that they have a responsibility to be the “human in the loop” and review responses before using them.

Prompt Builder puts power into the hands of admins to define prompt templates. It delivers personalized output while bringing the entire Customer 360 to your fingertips.

Resources

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback