Saturday, 2 March 2024

Hands on with Prompt Builder

Image generated by DALL-E 3 based on a prompt created by Bob Buzzard

Introduction

Unless you've been living under a rock, you'll have seen some big news from Salesforce in the Generative AI space this week (29th Feb 2024, for future readers) - Prompt Builder is Generally Available and Copilot is in Beta. 

I've been lucky enough to get my hands on both of these new features and have an initial dig around, so continue reading to find out how I got on with Prompt Builder. Like it's General Availability, my hands on experience with Copilot is coming soon!

Setup

Setting up Prompt Builder is very straightforward:

  1. Navigate to Setup -> Einstein Generative AI -> Einstein Setup and toggle it on
  2. Assign the Prompt Builder Manager/User permission sets
  3. Reload Setup, then navigate to Setup -> Einstein Generative AI -> Prompt Builder and start prompting.

Creating Prompts


I've mostly played with the Sales Emails prompts, aside from my Copilot experiments (see below). My initial use case was follow up emails for attendees of one of my World Famous Release Webinars, so I created a new custom object of Webinar and added a few fields that I wanted to pull into my prompt - the usual name and description, but also a couple of fields to capture the URLs of additional resources I wanted to send. I also added a Call to Action - this is a field to capture what I was hoping the attendees would do after attending - try out a couple of the features, for example.

Once I'd added the Webinar custom object, it didn't appear immediately in the prompt builder as a selectable Related Object. After checking the docs to make sure I hadn't missed a checkbox to make it available, I decided it must just be a timing thing - maybe the objects needed reindexing or the like. Then
I found that I couldn't create any prompts for a period of time - not sure how long, but it felt like 30-40 minutes - during that time the Related Object selector wouldn't populate at all. Then clearly whatever had been happening in the background finished, and I could select my new Webinar object.




My prompt is loosely based on the standard follow up email, but includes specific instructions and fields related to my webinar :

You are a Sales Executive and your name is {!$Input:Sender.Name} from an organization called {!$Input:Sender.CompanyName}. Your prospect is {!$Input:Recipient.Name}, who is the {!$Input:Recipient.Title}, from the company called {!$Input:Recipient.Company}.Your prospect {!$Input:Recipient.Name} attended a Salesforce release webinar that your company hosted.
When I ask you to generate a follow-up email to your prospect you must strictly follow my instructions below.
Instructions: """
The salutation must only contain the recipient's first name.
You must strictly not use "I hope this email finds you well" ,"I hope this email finds you doing well", or any other variation that expresses interest in the recipient's well-being to open the email.
Create a follow-up email conveying that you are following up on their attendance of {!$Input:Webinar__c.Name} to see if they need any additional information or support.
Mention the webinar, the number of attendees from {!$Input:Webinar__c.Attendee_Count__c} and include a summary of the {!$Input:Webinar__c.Description__c}. Express the hope that it was useful for them and that they will follow the call to action identified at {!$Input:Webinar__c.Call_to_Action__c}
End the email with details of the two additional resources that are available : {!$Input:Webinar__c.Resource_1__c} , which is {!$Input:Webinar__c.Resource_1_Detail__c} and {!$Input:Webinar__c.Resource_2__c}, which is {!$Input:Webinar__c.Resource_2_Detail__c}
Finish by indirectly encouraging your prospect {!$Input:Recipient.Name} to respond to your email by asking them if they need any further information, have questions or require assistance.
Generate a subject line that can increase open rate using words and content related to the email body.
"""
Now generate the follow-up email to your prospect.

Grounding the Prompt

I then provide a couple of sample records to test the prompt out. The Lead record is one that came with the org and will probably be familiar to anyone that has used a Salesforce Developer Edition before - Lauren Bailey from Omega, Inc. The webinar record is as follows:

The resolution section is useful when you are grounding the prompt with a number of inputs - it shows the expanded merge fields so you can see exactly what you'll be sending the AI model (although sensitive data will be masked by the Einstein Trust Layer, obviously):
You are a Sales Executive and your name is Keir Bowden from an organization called Credera. Your prospect is Lauren Bailey, who is the Director of Services, from the company called Omega,Inc.Your prospect Lauren Bailey attended a Salesforce release webinar that your company hosted.

When I ask you to generate a follow-up email to your prospect you must strictly follow my instructions below.

Instructions: """
The salutation must only contain the recipient's first name.
You must strictly not use "I hope this email finds you well" ,"I hope this email finds you doing well", or any other variation that expresses interest in the recipient's well-being to open the email.

Create a follow-up email conveying that you are following up on their attendance of Spring 24 Release Webinar to see if they need any additional information or support.

Mention the webinar, the number of attendees from 150 and include a summary of the Learn about the key new features and enhancements in the Spring 24 release of Salesforce.. Express the hope that it was useful for them and that they will follow the call to action identified at Enable dynamic forms and add related objects to your records home pages.

End the email with details of the two additional resources that are available : https://help.salesforce.com/s/articleView?id=release-notes.salesforce_release_notes.htm&language=en_US&release=248&type=5 , which is Salesforce Release Notes and https://www.youtube.com/watch?v=c4nKiYlQ6EU, which is Webinar Recording

Finish by indirectly encouraging your prospect Lauren Bailey to respond to your email by asking them if they need any further information, have questions or require assistance.

Generate a subject line that can increase open rate using words and content related to the email body.
"""

Now generate the follow-up email to your prospect.
I found that my original calls to action, even though they looked good in the record, didn't work very well when included in the prompt, so always have a look at the resolution the first couple of times.

The Response


The response from OpenAI GPT 3.5 Turbo was pretty good I thought, although maybe a little brusque - I'll probably rework it to a slightly more chatty version, but it's a great start for a small amount of work:
Subject:
Enhance Your Salesforce Experience with Spring 24 Release Insights

Body:
Hello Lauren,

I trust you found the Spring 24 Release Webinar insightful. With 150 attendees, we hope you gained valuable insights into the key new features and enhancements in the Salesforce Spring 24 release. The webinar highlighted how to enable dynamic forms and add related objects to your records home pages.

For further exploration, two additional resources are available:
- Salesforce Release Notes: https://help.salesforce.com/s/articleView?id=release-notes.salesforce_release_notes.htm&language=en_US&release=248&type=5
- Webinar Recording: https://www.youtube.com/watch?v=c4nKiYlQ6EU

Should you require any additional information, have questions, or need assistance, please feel free to reach out.

Best regards,
Keir Bowden
Credera

Grounding with Apex/Flow

I can see I'll be doing a lot of grounding with pro or low code - if I'm sending an email regarding a product I'll probably want to include a rate card and maybe some contractual information for example.  Grounding with Flow is very straightforward, and once you choose a Template Triggered Prompt Flow and pick the Sales Emails capability, there's a nice screen to define the object types you are using :


Apex is a little different - you define a class with an invocable method that defines the capability, then define Request and Response inner classes to manage the input and output parameters:

@InvocableMethod(label='Price for Lead' description='Gets the price of a product for a lead' 
                 CapabilityType='PromptTemplateType://einstein_gpt__salesEmail')
public static List<Response> getProductStandardPrices(List<Request> requests)  
        --- --- ---
public class Request {
    @InvocableVariable(required=true)
    public User sender;

    @InvocableVariable(required=true)
    public Lead recipient;

    @InvocableVariable(required=true)
    public Webinar__c relatedObject;
}

public class Response {
    @InvocableVariable(required=true)
    public String Prompt;
}

Apex is also a little different in that I couldn't get it to work! Even after copy/pasting the example in the Salesforce help, it wouldn't show up in the Resources selector. I'm sure this will be resolved soon, and as Prompt Builder has been one of Salesforce's more rapid features to go GA, I'm okay with their being a few glitches. As I've written before, I'll take a bit of additional effort tracking down issues if it means I get my hands on things earlier.

More Information





No comments:

Post a Comment