Admins / Consultants / Developers

Build Your First Prompt With Salesforce Prompt Builder

By Andrew Cook

Announced in Summer ‘23 and recently made available in Spring ‘24, Prompt Builder (formerly Prompt Studio) is here to allow every admin to be a prompt engineer. But how exactly does it work, and what does a good prompt look like?

In this article, we’ll break down what prompts are and how they differ from prompt templates. We’ll then go through the setup in creating your first prompt template before going through the steps to achieve this. We’ll even throw in a pretty good example prompt template to get you started. Without further ado, let’s get started!

What Is a Prompt?

A prompt is a specific instruction or input provided to an AI model to generate a desired output, such as text, images, or code. Essentially, it’s a way to guide the AI in producing content that aligns with a particular goal or theme.

For example, let’s consider a text generation model like OpenAI’s ChatGPT. If you want the model to write a short story about a journey through space, you would provide a prompt like: Write a short story about a journey through space. The model then uses this prompt to generate text that fits the given theme.

Similarly, in the case of image generation, you might provide a prompt like: Generate an image of a serene beach at sunset. The AI model then interprets this prompt and generates an image that represents a beach scene during sunset.

In essence, prompts serve as cues or instructions for the AI model to follow when generating content, helping to shape the output according to the desired criteria or theme.

What Is Prompt Builder?

Prompt Builder is the tool that allows you to create specific prompt templates within Salesforce. These differ from generic prompts used in generative AI in a few key ways:

  1. Structured Templates: Einstein prompt templates are pre-defined templates designed specifically for Salesforce users to streamline various tasks within the Salesforce ecosystem. These templates are structured and tailored to common use cases and workflows within Salesforce.
  2. Integration with Salesforce Data: Einstein prompt templates are integrated with Salesforce data and workflows, allowing users to leverage their existing Salesforce environment when generating content. This integration enables the templates to provide more contextually relevant suggestions and recommendations based on Salesforce data.
  3. Built-In AI Capabilities: While both generic prompts and Einstein prompt templates utilize AI, the latter often include built-in AI capabilities specific to Salesforce, such as Natural Language Processing (NLP) for analyzing customer interactions or predictive analytics for forecasting sales trends. These AI capabilities are tailored to Salesforce-specific use cases and are designed to enhance productivity and decision-making within the Salesforce platform.
  4. Customization and Flexibility: Einstein prompt templates offer customization and flexibility to meet the diverse needs of Salesforce users. Users can customize templates to align with their specific requirements and preferences, ensuring that the generated content meets their unique business needs.

Overall, Einstein prompt templates in Salesforce provide a more tailored and integrated approach to leveraging AI-generated content within the Salesforce platform, with a focus on enhancing productivity, decision-making, and user experience for Salesforce users.

Now we’ve got the fundamentals of prompts out of the way, let’s build our first prompt!

Einstein AI Setup

First things first, let’s enable Prompt Builder!

To do this, simply go into Setup, search for Einstein Setup, and turn on Einstein. Don’t forget to refresh your page after you’ve done this so the new Prompt Builder options appear in Setup.

Next, we need to enable Copilot. To do this, search for Einstein Copilots in Setup, and turn on using the toggle.

Last, you need to assign the relevant permission sets. There are two Permission Sets for Copilot: Einstein Copilot for Salesforce Admin and Einstein Copilot for Salesforce User.

Prompt Template Types

There are different types of prompt templates, each with a specific use case.

First up, there are Email templates. This is where Einstein assists in crafting tailored emails, ensuring a touch of personality in every message. For example, you may have a customer service template with a pre-filled greeting, issue acknowledgment, and a field for the support agent to provide a resolution.

Next, there is Field Generation. These templates help streamline repetitive tasks to save time for users. For example, you may have a product description template that automatically populates key details (like dimensions or materials) based on product listings in your database.

Then, we have Flex templates. Here, Einstein offers the flexibility to build templates precisely matching your users’ unique needs. For example, you may have a sales opportunity assessment template with customizable fields to capture deal size, competition, and the customer’s pain points.

And lastly, there are Record Summary prompt templates. These create a rich-text summary for a Salesforce record based on the record’s data and would be used with the Copilot sidebar.

Creating Your Prompt Template

Once you have decided which type of prompt template you want to create, it’s now time to build it!

First of all, you will need to select which object the prompt template is going to be utilized for, selecting the object that contains the fields you want Einstein to help users complete. For example, to create product descriptions, select Product, or to create opportunity record summaries, select Opportunity.

Selecting next will take you to the Prompt Template Workspace.

  1. Prompt Template Workspace: Enter your natural language prompt.
  2. Resources: Select which resources you want your prompt to include.
  3. Resolution: View your prompt with record data selected by the user. The data replaces the placeholders initially created in the prompt, sourced from the chosen merge fields, flows, or Apex code.
  4. Response: Preview the response for selected records. Verify the output for accuracy and safety before using the template.
  5. Configuration: Select which model type to use for your prompt.

Example Prompt

The following is an example prompt template for a lead summary:

Using the details below, generate an output formatted as HTML rich text.
Instructions:
“””
Summarize the Lead record based on the data below.
Do not generate any CSS. Do not generate code block formatting.
If a key does not have any related name value pairs, then do not include that key in your summary. Sections must not be included if all of its related keys do not have any values or have placeholder values. For example, if there is no status provided in the data, then there should not be a Status section. Keys that have no value or placeholder values such as “PROVIDE:” followed by the key name should be excluded from the summary.
If a key, section, or piece of information is excluded or not provided, you must not generate an error message or any sentence describing why it has not been provided or explaining what data is missing.
There may be multiple keys with data for the same section. If there are and these keys have data, then include data from both keys in your description for that section heading in your output. There should only be one section with that name for your output that includes data from both keys combined.
The headings ‘Summary’, ‘Status’, and ‘Activities’ must be present in that order.
The Summary Data object should be summarized under the section titled “Summary”. This title must link to the lead’s record URL. After, there should be a paragraph describing the other related values in the summaryData key. The record URL should not be included or linked in the description paragraph.
When included, Status and Activities should also summarize in a paragraph their corresponding data under sections with those same names.
If the Lead Score is empty, then exclude it from the summary and do not mention it at all.
Section headers should be bold and wrapped in <p>. The Summary title must also link to the Record URL. Then, on the next line should be a paragraph description wrapped in <p>. Between each section should be one new line.
For Activities and any meetings, if the date is before today’s current date, then mention that there is no upcoming meeting scheduled along with the date the last meeting was on. If the next scheduled meeting is after the current date, then mention it as an upcoming meeting. If there is no activity, then exclude the Activities section.
Each paragraph description should be a maximum of three complete sentences written concisely using the third person perspective and prioritizing active voice. Avoid filler phrases or transition sentences. Emphasize only one important item for each description, such as a date, name, or title, by italicizing them.
List all dates in the format “Month Date, Year” without the time stamp. For monetary values, convert the currency code to its corresponding currency symbol. You must not include the currency code. Only include the currency symbol when talking about monetary values. Otherwise, do not include currency in your summaries or descriptions.
You must spell out numbers that refer to amount of objects, if the number is lower than 10, such as ‘three contacts, four accounts, 12 meetings’ etc.
“””
Data:
“””
{
“summaryData”: { “Lead Name”: {!$Input:Lead.Name},
“Record URL”: “/{!$Input:Lead.Id}”,
“Lead’s company”:{!$Input:Lead.Company},
“Lead’s job title at the company”:{!$Input:Lead.Title},
“Lead was created on”: {!$Input:Lead.CreatedDate},
“Lead Source”: {!$Input:Lead.LeadSource},
“status”: {“Current status of the Lead”: {!$Input:Lead.Status}},
}
“””
The response should be in EN_US.
Now generate only the HTML rich text.

This was created as a Record Summary prompt template. The summary data fields in this prompt template are all based on standard Lead fields, so this should work for most, if not, all orgs. Let’s take a look at the output from this below:

For field generation prompt templates, you will need to select which field to use it with. This can be done via the Lightning App Builder, as shown below:

Best Practices

To make your prompts clear and easy to understand, keep them short and avoid technical language. Instead, use everyday language and guidelines for natural conversation. For better context, ask the model to play a role (like a salesperson or support agent) and define their goal. For example, you might say: Imagine you’re a marketing executive inviting key customers to an event.

Grounding your prompt templates in Salesforce is essential for creating relevant and accurate responses. Incorporate Salesforce-specific terminology and scenarios to ensure the prompts align with your business context. This helps the model understand and respond appropriately to Salesforce-related tasks and interactions.

Experiment with different prompt styles to see how they affect the model’s response, and gather feedback from users to refine your templates. Consistency in your writing style, including word choice and punctuation, helps the model generate consistent responses. To distinguish between context and instructions, include a separate instructions section in your prompts and clearly state what type of content you expect from the model. Start with templates from the Example Prompt Template Library and tailor them to your needs, paying attention to the language and writing style used.

Summary

And there we have it, you’ve successfully built your first prompt template! We’ve gone over what a prompt is and how it differs from a prompt template before further exploring the ‘nitty gritty’ of Prompt Builder and the different components of the Prompt Template Workspace. Finally, we’ve covered some best practices that all admins should adhere to when building their own prompt templates. And to top it off, there’s even an example prompt template to get you started.

Have you got any prompt template examples you’d like to see? Let us know in the comments below.

The Author

Andrew Cook

Andrew is 14x certified and has worked in the ecosystem for 12 years.

Leave a Reply