This lesson walks through a step-by-step build-along for automating the introduction email process using two Salesforce tools: Prompt Builder and a Screen Flow. The Agentforce toolset works like a system of bi-directional puzzle pieces—different elements can pass information to each other in both directions.
For example, when building a prompt template, you can inject data from a Flow into the prompt template as a resource. The reverse is also true: you can build a Flow and use the Action element to retrieve AI-generated data from a prompt template and feed it back into the Flow. That’s exactly what we’ll be doing in this exercise.
SaaS United operates a global SaaS network, connecting professionals, investors, and strategic partners. The Business Development (BD) team is responsible for introducing key contacts within the SaaS ecosystem, fostering relationships, and driving partnerships. Currently, BD team members manually:
This manual process is inefficient, requiring an estimated 10-15 minutes per email. Given that each BD rep sends 10-20 introductions per day, this results in 2-5 hours of lost productivity per rep daily—time that could be spent on higher-value relationship-building activities.
Additionally, the lack of standardization in email structure and tone creates inconsistencies in professional introductions. SaaS United needs an AI-driven automation solution to:
To address these challenges, we will build an AI-driven email automation solution using Prompt Builder and Screen Flows. This solution will automatically generate personalized emails based on the biographies of two contacts. By integrating a flexible prompt template with a screen flow, users will be able to:
This automation significantly reduces manual effort while standardizing a core business process.
To build an AI-driven email automation solution, the first step is to create a structured Prompt Template in Salesforce. This template will dynamically generate email introductions based on the biographies of two contacts.
This prompt parses the biographies of two contacts, synthesizes relevant information, and generates a professional yet friendly introduction email.
The Salesforce AI Prompt Builder allows you to pull data from objects or enter free text. In this case, we are pulling two Contact records as inputs.
Before writing the actual prompt, it’s important to structure it properly to ensure the AI generates high-quality responses. A well-structured prompt for this exercise will include:
INTRO:
OBJECTIVE:
INPUT INFO:
STRUCTURE OF RESPONSE:
KEY DETAILS:
EXAMPLE:
To improve the quality of the email output, use ChatGPT to refine the prompt:
Utilize this template to create a prompt for Salesforce Prompt Builder that introduces two contacts based on their description field. The email should be concise, professional, signed as SalesCraft AI assistant, and should call for the two individuals to meet.
After generating the initial draft, use ChatGPT to refine the prompt by improving clarity, tone, and structure. Incorporating AI-driven refinements ensures the generated email feels more natural and engaging.
Once you have refined the prompt, it’s time to add it into Prompt Builder. Navigate to the Prompt Writing Area in Prompt Builder and paste the refined text.
Next, replace the placeholder input fields with Salesforce record variables:
Contact 1:
FIRST NAME: {!$Input:Contact1.FirstName}
BIO: {!$Input:Contact1.Description}
Contact 2:
FIRST NAME: {!$Input:Contact2.FirstName}
BIO: {!$Input:Contact2.Description}
Now the prompt has been structured, refined, and tested, finalize it with clear objectives and formatting:
INTRO:
You are tasked with generating an email that introduces two Salesforce contacts using key information from their description fields.
OBJECTIVE:
Craft a concise and professional email that highlights the most relevant details from each contact’s description, encouraging them to meet and explore potential collaboration opportunities.
INPUT INFO:
Contact 1:
FIRST NAME: {!$Input:Contact1.FirstName}
BIO: {!$Input:Contact1.Description}
Contact 2:
FIRST NAME: {!$Input:Contact2.FirstName}
BIO: {!$Input:Contact2.Description}
STRUCTURE OF RESPONSE:
Salutation: Address both contacts with their first name.
Briefly introduce each contact using the key details from their respective description fields.
Explain why their meeting could be mutually beneficial.
Include a clear call-to-action inviting them to schedule a meeting.
Closing: End the email professionally and sign off as
“Luna Lovgarden,
SalesCraft AI assistant”
KEY DETAILS:
The email should be concise and maintain a professional tone throughout.
It must incorporate specific details from each contact’s description to personalize the introduction.
Ensure a direct call-to-action is included, urging them to meet.
EXAMPLE:
Dear Jane and John,
I hope this message finds you both well. I’m excited to introduce you to one another, as I believe your unique expertise could spark some truly innovative opportunities.
Jane, your impressive track record as a marketing strategist—with your creative leadership in digital campaigns and brand management—continues to set industry benchmarks.
John, your robust background in sales and business development, coupled with a consistent record of driving revenue growth, makes you a powerhouse in the field.
I’m confident that a conversation between you could lead to a dynamic collaboration. Please consider scheduling a meeting at your earliest convenience to explore potential synergies.
Best,
Luna Lovgarden
SalesCraft AI assistant
Once the prompt template has been created, it’s time to test and refine it to ensure it produces high-quality email introductions. We’ll preview generated responses using real or sample data.
Contact 1: First Name: Alex
Description: “Alex is a software engineer at XYZ Tech specializing in AI-driven applications.”
Contact 2: First Name: Jamie
Description: “Jamie is a product manager at ABC Innovations focused on AI and machine learning strategy.”
Once the AI generates the email, carefully review the output for accuracy, clarity, and professionalism. Ask yourself:
Once satisfied with the AI-generated output, click Activate to make the prompt available for use in Salesforce Flows:
Now that the Prompt Template has been created and tested, the next step is to integrate it into a Salesforce Screen Flow. This will allow users to input contact details, generate the email, review it, and send it directly from the Flow.
Pay special attention to the Object API Name field in the last screenshot. Why are we selecting Case here? Aren’t we working on the Contact?
Well… yes, we are, but this is a lookup field. We need to lookup a contact. Salesforce needs a base record from which to perform the lookup.
Really, any object that has a lookup to the contact record would work here. We’ve just arbitrarily chosen Case.
Now that the AI-generated email has been created in Prompt Builder, the next step is to display it within the Salesforce Screen Flow for review and potential edits before sending.
Before finalizing the Flow, it’s essential to test and debug it to ensure everything works as expected.
Now that we’ve determined the results from the screen flow are good, we can finish out the process by adding the remaining elements users need on the last screen in the flow.
Back on the last screen element in the flow, add a Text Component above the generated email. Label it as the Subject.
The final step in the automation process is configuring Salesforce to send the AI-generated introduction email. This is done using the Send Email action in Flow Builder.
Screen -> Email Template Preview -> Edit Generated Email
(the AI-generated, user-edited email).True
.Screen -> Email Template Preview -> Subject
.This step is not included in the build-along video. We need to manually gather the recipient email addresses into a single text variable so they can be passed into the Recipient Address Collection
field.
EmailList
.Get Records
elements.Add Email Addresses to Collection
.EmailList
variable.Recipient Address Collection
field, select the newly created EmailList
resource.Before finalizing the flow, let’s test its functionality and verify that emails are sent correctly.
EmailList
variable.Once everything is working as expected, click Activate to make the flow live. This is your final layout!
Now that the flow is complete, we need to add it to the Contact Record Page for easy access.
You made it! Congrats on building a more complex solution using flex prompt template inside a flow to solve for the business requirement!