Location>code7788 >text

Salesforce AI Specialistsheet Prompt Builder

Popularity:639 ℃/2024-10-07 21:43:59

This reference:

/watch/UUAxcUfHYGAxH3D9wV1RxJ

/s/articleView?id=sf.prompt_builder_about.htm&type=5

/guidelines/conversation-design/overview/

I. What is Prompt Template

We have more or less used some generative AI tools like chat gpt. imagine if we apply gpt in our salesforce platform, we can imagine a lot of scenarios. For example:

  1. I am a hotel receptionist. A guest has booked our company's hotel, and I send a welcome booking email to the customer, which includes booking information, hotel address, and may add some content such as weather forecast or four weeks tour. We can send these key information to gpt, and then gpt will return a draft version of the email to us, and we will review it and send it if we think it's good.
  2. I'm a sales person and there is an OPPORTUNITY I've just taken over and I'm looking for an organization/summary of the at-a-glance information about this OPPORTUNITY.
  3. I'm a customer service agent who has recorded a lot of comments in response to multiple communications with customers for their cases, and I'd like to quickly organize these comments.
  4. I am an AE and I have a potential client that I would like to email to market our company's products for better publicity as well as to generate potential opportunities.

There are many scenarios that we can brainstorm on our own. Let's take scenario 4 as an example, the demo is from the official trailhead with simple modifications.

You are an account executive named York Zhang from a company named XXX. You are writing to Tom, who is a director at YYY. They have been a customer of yours since 2024/10/1.

You are attempting to persuade Tom to sign up for "Dream It Possible", which is described as 
"I will run, I will climb, I will soar I'm undefeated, ooh Jumping out of my skin, pull the chord Yeah I believe it, ooh The past is everything we were Don't make us who we are So I'll dream, until I make it real".

Describe the business value of "Dream It Possible" in the context of organizations based in New Jersey. Write the message in the form of an email directed toward a single individual, written in English. The message should evoke enthusiasm with intensifiers, but limit the use of exclamation points. Express casualness using contractions, referring to the recipient in second person, and using discourse markers. Limit the message to about 500 words, and do not address any content or generate answers that you don’t have complete data on. Follow these instructions strictly to generate only the message to be sent to the customer.

We sent this to gpt and got a reply from it.

We will find that the output of gpt is quite good, AE can save a lot of time in clenching and writing emails, so as to focus on other more important things. One problem is that many people's time is too valuable to manually input into the gpt every time, and then get the content to copy and paste or other operations. How to build a template to achieve the user through the point and click can be completely taken care of to get their information, this time the need for Prompt Template (Prompt Template).

In short, a Prompt Template is a reusable prompt.Prompt Templates include placeholders for specific details about the customer, the product, etc. Once these placeholders are populated with real, relevant data, they become truly personalized prompts. Once these placeholders are populated with real, relevant data, the Prompt Template becomes a truly personalized prompt. The ingredients and instructions are basically the same, but the output is customized to your business and target audience.Prompt template needs to be built with Prompt Builder.

II. Prompt Template components

We elicited the Prompt Template in Part 1 by building a Prompt to send to gpt and then returning our corresponding email, so if we want to make a common Template, do we have any guidelines to refer to? We can consider the following parts:

1. Participants Participant: Describes who is sending and receiving responses from the model. When describing participants, we can use merge fields that refer to record fields, streams, Apex, etc., which we will cover later. The participant in the above demo is York Zhang.

2. Setting  Settings: Provides contextual information to the model, such as the communication channel or content type that the response is targeting. Your Prompt Template Type determines your settings. For example, if you choose the Field Generation template type, your setting is Record Field.

3. Goal Goal: Describe what you hope to achieve with the model's response. Make sure to consider the user's context, preferences, and past behavior. You can use merge fields to add details to your goal. The goal in the above demo is: You are attempting to persuade Tom to sign up for "Dream It Possible"

4. Relationships Relationships: describe the relationships between the participants involved. Also mention how the response of the model can be associated/related to the participants. The relationships in the above demo are: Tom, who is a director at YYY. They have been a customer of yours since 2024/10/1

5. Data Data: Use merge fields to provide relevant CRM data for the model to use. In the above demo, we can use Data to achieve commonality. For example, we can replace the common template with data from the system for fields including but not limited to the following:

  • Your Name
  • Your Name's Company
  • Customer Name
  • Customer Role
  • Customer Company
  • Product Name
  • Product Description

6. Instructions Directive: tells the LLM what type of content you want and what it must include. Putting instructions in triple-quote boundaries helps LLM distinguish between prompt context and instructions. The instructions in the above Demo are:

Write the message in the form of an email directed toward a single individual, written in English.
The message should evoke enthusiasm with intensifiers, but limit the use of exclamation points. Express casualness using contractions, referring to the recipient in second person, and using discourse markers.
Limit the message to about 500 words, and do not address any content or generate answers that you don’t have complete data on.

7. Guidelines Guidelines: To minimize the possibility of hallucinations, give guidelines for the model it must follow. The guideline in the above demo is: Follow these instructions strictly to generate only the message to be sent to the customer.

8. Language Language: Tells the model in which language to generate the response. In the demo above, the language is English.

9. Style and Tone Style and tone: Give guidelines for modeling style and tone to follow。aforesaidDemo中的Style and tone: The message should evoke enthusiasm with intensifiers, but limit the use of exclamation points. Express casualness using contractions, referring to the recipient in second person, and using discourse markers.

Interspersed, an effective Prompt template should be considered:

  • What’s the goal of the prompt template?—By declaring the goal of the response first, you can better answer all the subsequent questions.
    What is the goal of the prompt template? --By first stating the goal of the response, you can better answer all subsequent questions.
  • Who is involved?—Describe the participants who send or receive the response, the relationship between the participants, and the relationship between the participants and the response.
    Who participates? -Describes the participants who send or receive the response, the relationship between participants, and the relationship between participants and the response.
  • What’s the context of the prompt template and the response?—Define a setting for the model response, the CRM data to ground the prompt in, and add a command that tells the model what to generate.
    What is the context of the prompt template and response? - Define the settings for the model response, the CRM data on which the prompt is based, and add commands that tell the model what content to generate.
  • What guardrails does this prompt template need to succeed?—You can add more information, such as instructions for the response’s style and tone.
    What guardrails are required for this prompt template to be successful? - You can add more information, such as a description of the response style and tone.

Beyond that, there are some officially recommended best practices below.

1. Make sure your prompt template is concise and easy to understand. Avoid industry jargon or technical terms. Instead, use natural language and conversational design guidelines.

2. Iterate your cue template. Try using different templates to achieve the same goal and see how the components affect the model's response. Get end-user feedback to see how well your cue template generates the desired response.

More can be viewed:/s/articleView?id=sf.prompt_builder_best_practices.htm&type=5

III. Enabling Prompt Builder and Permission Configuration

For Prompt Builder, there are two permission sets to use.

authority name Privilege Description
Prompt Template Manager To create and manage Prompt Templates in Prompt Builder
Prompt Template User Accessing and running Prompt Templates outside of Prompt Builder

 

We need to sign up for an environment with ai functionality first, which can be done by visiting this trailhead and then clicking Sign up for 14 days of free environments:/content/learn/projects/quick-start-prompt-builder/get-started-with-prompt-builder

How to enable Prompt Builder?

1. Setup Search for Einstein Setup and then enable einstein.

2. Set the permission set. If the user wants to configure the Prompt template, he/she needs to have the Prompt Builder Manager privilege.

3. If you need to use the einstein for Sales feature, you need to enable it. setup search for Einstein for Sales and then enable Sales Emails.

After refreshing the page, you can Setup Search Prompt Builder to use it.

 IV. Prompt Builder Components

When we enter the Prompt Builder, we can see the following similar page, we can split it into 6 parts.

1. Prompt Template Workspace: Enter the location of the natural language prompt. Provide instructions to the LLM to help create the desired output. we can also use the merge field for grounding.

2. Resource: when we need to use the merge field for grounding, we can choose in the resource, resource can choose the following:

  • Flows Merge Field: When your logic of the current standard merge field can not be resolved, you can use Flow Merge Field, for example, we want to organize Account data in all his Open Case information, we can consider the use of this type, the first through the Flow to select theTemplate-Triggered Prompt Flow type to build, and then we can select to this type in Prompt Builder.

  • Apex Merge Field: the same as Flow Merge Field, if the standard function can not be handled, we can use apex to build complex logic to achieve the grounding for dynamic input. apex class need to use theInvocableMethodannotation to make the declaration. Take an officially provided example:
public class OpenCasesPrompt {
    @InvocableMethod(label='Open Cases'
        description='Find Cases for an Account'
        CapabilityType='PromptTemplateType://einstein_gpt__fieldCompletion')
    public static List<Response> getCasesPrompt(List<Request> requests) {
        // Validate the expected number of requests as an input
        if (() != 1)
          throw new ListException('The requests list must contain one entry only');
        Account a = requests[0].RelatedEntity;
        ID searchAcctId = ;
        List<Case> cases =
            [SELECT Id, Subject, Description
             FROM Case
             WHERE AccountId = :searchAcctId AND Status != 'Closed'
             WITH USER_MODE];
        string responseData = null;
        if(()) {
            responseData = 'There are no open cases.';
        } else {
            for(Case c : cases) {  
                responseData =
                   (responseData != null) ? responseData + '\n' : '';           
                responseData += ('Case details: {0}, {1}.',
                    new List<Object>{, });
            }
        }
       
        List<Response> responses = new List<Response>();
        Response res = new Response();
         = responseData;
        (res);
        return responses;
    }
    
    public class Request {
        @InvocableVariable(required=true)
        public Account RelatedEntity;
    }
    
    public class Response {
        @InvocableVariable
        public String Prompt;
    }
}
  • Current Organization Merge Field: You can select this type when you want to use the current org's information grounding for dynamic input, for example, you need to use the current Org's Fax information as the dynamic parameter grounding.
  • Current User Merge Field: You can choose this type when you want to use the current running user's information grounding for dynamic input, such as the need to use the current user's Email as a dynamic parameter grounding.
  • Record Merge Field: When you want to ground some field values of the current record for dynamic input, you can choose this type, for example, you want to use the Case Type of the current record as a dynamic parameter grounding.
  • Record Related List Merge Field: When you want to ground the current record related list data for dynamic input, you can choose this type, for example, you need the Case Histroy of the current record to be grounded as a dynamic parameter. For example, click on the Case in the figure below, then you can select the Case Histories (all histories, if you want to filter, you need to use apex/flow merge field) at the bottom.

3. Configuration: allows you to select the current Prompt you want to use which model type to generate dynamic content, for example, you can choose GPT 3.5 / GPT 4.0 and so on.

4. Selected Record: When our content area contains merge field, we need to select the data, this data will replace the merge field dynamic grounding.

5. Resolution: allows you to select specific data to view the Prompt, this selection of data will replace the merge field information in our content area.

6. Response: allows you to preview the generated content, we can use the Response model to know whether our content is in line with the requirements and whether the generation of our expected content.

IV. Prompt Template Type

With the above steps, we can start working on creating Prompt templates. So what are the types supported by Salesforce and what is the introduction of these types.

Prompt Template Type Description
Field Generation Generate content for the record field in Lightning Experience. In Salesforce, the user clicks a button to run this prompt and populate the field with output.
Record Summary Summarize record data to get a comprehensive view of the record. Record summary prompt templates are used by the Summarize Record standard invocable action. In Einstein Copilot, they are used by the Summarize Record standard copilot action.
Sales Emails Generate personalized customer emails based on recorded data.
Flex Generate content for any commercial purpose not covered by other templates. The Flex Tip template allows you to define your own resources. One of the most flexible.

These are the template types that we can choose from when we create our Prompt. In addition to our custom Prompts, salesforce also provides some standard Prompt templates. The standard template types include one: Record Prioritization for Einstein Copilot, do not expand here, currently only focus on the above four types. Here we only give an example of Field Generation and Sales Email, other types you can check the official documents.

1. Examples of Field Generation

Our need is to organize what are the current open cases for Account and make some concise summary of those open cases. Let's think about what we need to consider before developing the implementation.

  1. open case instead of all cases, so we can't use related lists, we can only pass variables via apex or flow.
  2. Summarize against open case information rather than against the current data, so use the Field Generation type.
  3. The assignment of this field is required to be generated based on AI, so you need to enable dynamic form, and then you can choose to generate based on the specified prompt template for this field.

Then we implement it according to the above steps. The specific steps can be referred to:/s/articleView?id=sf.prompt_builder_add_flow_without_data_cloud_field_gen.htm&type=5

Build the flow: the type of flow we choose is Template-Triggered Prompt Flow, and the input is auto input, and the object is set to account. there are two branches for whether the current account has an Open Case or not, and if there is no Case, we add a No Case Prompt Instruction. If there is no Case, then add a Prompt Instruction for No Case, and if there is an Open Case, then add the Subject and Description to the Prompt Instruction. The final output we can see is the Prompt Instruction.

Construct Prompt Builder: We fill up the template content through instruction, and reach dynamic input through merge field, we can see that there are two dynamic variables in the demo, AccountId and Open Case information. Through Preview we can see that open AI can be dynamically grounded based on the system data. If the response after clicking Preview meets our expectation, we can be active in this template.

Configure the field: first you need to upgrade the form to dynamic form, and then select the corresponding prompt template, so that in the details page click on the right side of the field, you can pop up the einstein bot to dynamically enter the content, if we feel satisfied, you can click on the use so as to complete this function.

The principle of all templates, Human-in-the-loop, must be to ensure that the end user is in the process of review.

2. Sales Email Example

Here we directly use the official demo for example. Recommend a product to Lead and send an invitation to a meeting. We can see that most of the merge field is used, and the rest is not extra special.

Let's do a little demonstration.

Summary:In this article mainly introduces the use of Prompt Builder and Prompt Template some of the rules. There are errors in the article, welcome to point out, do not understand welcome to leave a message. Other parts of the document can be based on their own view.