Skip to main content
Join the Agentforce Hackathon on Nov. 18-19 to compete for a $20,000 Grand Prize. Sign up now. Terms apply.

Get Started with Prompt Builder

Learning Objectives

In this project, you’ll:

  • Create and test a prompt template that includes merge fields.
  • Associate a prompt template with a text field for field generation.

Streamline Content Generation

Prompt Builder gives your organization an easy way to tap into the power of generative AI. It helps you combine existing data with some well-crafted instructions to create prompt templates. In a nutshell, prompt templates are used to create prompts, the messages sent to large language models (LLMs) in order to generate content.

Prompt templates are special because they include placeholders for specific details about customers, products, cases, and more. Each time a prompt template is used, it merges the data to create a unique, personalized prompt, which results in a personalized response. And since prompt templates are reusable, they’re a key part of a scalable AI implementation. For a more in-depth explanation of prompts and prompt templates, check out Prompt Fundamentals.

In this project you get hands-on by creating a prompt template, and then use it to get actual generated responses from an LLM. Specifically, you’ll focus on a scenario everyone is familiar with: customer support cases. In an effort to boost productivity and customer satisfaction, you want to use generative AI to summarize the details of a case in about 100 words. This enables agents to get up to speed quickly and makes it easier to identify cases that deserve special attention.

Screenshot of a case with a populated Quick Summary field.

Sign Up for a Trial Org with Einstein Generative AI

To complete this project, you need a special, 14-day custom playground that contains Einstein AI and our sample data.

  1. If you haven't already, click the I can receive a password email checkbox in the beginning of the unit.
  2. Click Create Playground.
  3. Follow the prompts.
Note

This custom playground 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 org that we recommend.

If you’re working on related Einstein AI content in Trailhead, you’ll also use this org for these projects:

Create a Field Generation Prompt Template

In this project, you want a case summary to appear in a text field on the record. To save a little time, Team Trailhead has already created a field named Quick Summary and placed it into the page layout. At this point there’s nothing special about it, but let’s change that! You start by creating a prompt template.

  1. If you don’t already have your Einstein AI-enabled trial org open, scroll down to the Challenge section and click Launch to open it.
  2. Click Setup icon and click Setup. The Setup page opens in a new tab.
  3. In the Quick Find box, enter einstein setup, then click Einstein Setup.
  4. Turn on Einstein by clicking the toggle. It may already be on if you’ve completed the Quick Start: Einstein Copilot project.

Einstein setup page.

  1. Refresh your browser window. This reveals new admin settings now that Einstein is enabled.
  2. In the Quick Find box, enter prompt, then click Prompt Builder.
  3. Click New Prompt Template.

New Prompt Template button

For this example you use the Field Generation type of prompt template, so leave that as is.

  1. For Prompt Template Name, enter Quick Summary.
  2. For API Name, enter Quick_Summary.
  3. For Template Description, enter A short summary of case details.
  4. For Object, find and select Case.
  5. For Object Field, find and select Quick Summary.
  6. Click Next.

Great, you now have the start of a prompt template. It’s time to build it by writing some clear instructions that describe what you want from the LLM. As you learn in the Prompt Fundamentals badge, there are several things you can add to get better results. In this example you include direction for the overall goal, size limits, and some guardrails.

Writing a good prompt is somewhat of an art form, so for this project we give you a prompt that we know works well.

  1. Paste the following text into the Prompt Template Workspace.
Summarize the concatenation of the contents of the comment bodies of COMMENTS along with the text from SUBJECT, the case priority which is PRIORITY, and the case type which is TYPE.
Keep the response to a single short paragraph.
  1. Click Save.
  2. For Models, choose OpenAI GPT 4.

Model selection in Template Properties.

There are several models to choose from in your Einstein AI-enabled org, and OpenAI GPT 4 produces some great results.

This sample text includes a few placeholders in all caps for things like case priority. Let’s replace those with actual merge fields so the LLM can create a custom tailored response for a variety of situations.

  1. Place the mouse cursor in front of the word PRIORITY in the Prompt Template Workspace.

Placement of cursor before the word priority.

  1. Click in the Resource box to open the list of resources.

Expanded list of resources.

  1. Click Case, then click Priority.
    A merge field is inserted into text as blue text.
  2. Delete PRIORITY to leave behind just the merge field. It should now look like this:

Priority text deleted and replaced with resource insert.

Repeat the process to replace the COMMENTS, SUBJECT, and TYPE text placeholders.

  1. Place the mouse cursor in front of COMMENTS.
  2. Click in the Resource box. Select Case, then click CaseComments.
    Note: Notice the colorful text, it indicates that this is a related list. (The text color may vary depending on your browser settings.)
  3. Delete COMMENTS to leave behind just the merge field. It should now look like this:

Comments text deleted and replaced with resource insert.

  1. Place the mouse cursor in front of SUBJECT.
  2. Click in the Resource box. Select Case, then click Subject.
  3. Delete SUBJECT to leave behind just the merge field.
  4. And finally, place the mouse cursor in front of TYPE.
  5. Click in the Resource box. Select Case, then click Case Type.
  6. Delete TYPE to leave behind just the merge field.

With merge fields in place, your prompt template should look like this.

Prompt Builder window with completed contents.

It’s just that easy to ground your prompt in real data. Now that your prompt template includes merge fields and good instructions, it’s time to test it out. Prompt Builder makes it easy to try your prompt template with actual data. All you need is a sample record to draw from.

  1. In the Related Record box, find and select case 00001002.

Related record input box.

  1. Click Save & Preview.
  2. Click Activate.

This is the moment you’ve been waiting for! Your instructions have been sent to the LLM, and in response you get a generated summary of the case in just a few sentences. Yours may appear a little different than the screen captures in this project. That’s OK, it’s normal for LLMs to respond to the same prompt in more than one way.

Enable Dynamic Forms for Cases

Your prompt template is ready to go. The last step is to update the page layout so that your customer support team can use the new prompt template.

  1. While still on the Prompt Builder page, verify that you’ve clicked Activate.
  2. Close the Setup tab to return to the Sales app.
  3. In the Navigation Bar, click Cases. (You may need to click More to find it.)
  4. Click the down arrow next to Recently Viewed, and select All Open Cases.
  5. Click case number 00001002.
  6. Click Setup icon and click Edit Page.
  7. Select the contents of the Details section [1].

Details section selected with Record Detail opened.

  1. With the Details section selected, click Upgrade Now in the Record Detail to upgrade to Dynamic Forms.
  2. Click Next.
  3. Select the Case Layout radio button.
  4. Click Finish.
  5. In the Details section, click the Quick Summary field.
  6. For Prompt Template, find and select Quick Summary.

Screenshot of Prompt Template selection box.

  1. Click Save and then Activate.
  2. Click the Assign as Org Default button.
  3. Click Next and then Save.
  4. Click the back arrow in the upper left to leave the Lightning App Builder.

Excellent, the Quick Summary field is ready to use Einstein Generative AI. You can tell because the edit button has a little star next to it.

Screenshot of a field with updated icon.

Let’s try it out.

  1. Click Edit icon on the Quick Summary field.
  2. Click Get help with Einstein icon on the right of the field.
    This automatically opens up the Einstein overlay, using your prompt template to start a new conversation. In a moment Einstein will suggest a case summary. Again, yours may appear a little different than ours.

Einstein overlay with a suggested case summary.

This gives your users a chance to review the summary, and even continue the conversation with Einstein to work together on a revised version. For this example, you just accept the first suggestion. There should be a Use button in the Einstein overlay. If there isn’t, just refresh the page and do steps 1 & 2 again.

  1. Click Use.
  2. Click the X to close the Einstein overlay.
    Notice that the Quick Summary field is filled in.
  3. Click Save.

With just a few clicks, your users can access the power of Einstein Generative AI to quickly create useful content so that they can focus on more important things. The conversational nature of Einstein lets them refine the generated content in real time, and they can always tweak it after it’s placed into the field.

Great job creating such a helpful prompt template. Have fun experimenting in the Prompt Builder to discover other ways to automate text generation for your organization.

Resources

在 Salesforce 帮助中分享 Trailhead 反馈

我们很想听听您使用 Trailhead 的经验——您现在可以随时从 Salesforce 帮助网站访问新的反馈表单。

了解更多 继续分享反馈