Hey, rockstar admins! Prepare to skyrocket your prompt templates to new levels with your automation prowess using Flow Builder! Mastering the dynamic duo of Prompt Builder and Flow Builder will empower you to create powerful prompt template actions for your agents, setting you up for remarkable success as you lead artificial intelligence (AI) transformations in your company.
Watch the video from Dreamforce 2024: Automate This! Build Flows for Prompt Builder.
Prompt Builder: Your AI superpower
Prompt Builder is a fantastic tool for admins to build trusted AI with ease using reusable prompt templates that summarize and create content, increasing overall user productivity. If you’re just learning about Prompt Builder, I recommend you check out The Ultimate Guide to Prompt Builder blog. To further enrich your prompts, ground them in data to provide that use-case specific, relevant data that’s not in your LLM’s trained knowledge for that more personalized, relevant response using accurate and current data.
Flex your flow building skills
As an admin, one of your superpowers is building automation, and the tool to use is Flow Builder. You already use Flow to do some pretty cool things in your org. Flex your skills by building flows that go beyond the basic record fields and record related lists to perform the more complex data gathering to ground your prompt templates.
Building prompt flows
To build flows for use with prompt templates, you’ll build template-triggered prompt flows. Now that’s a mouthful, so I call them prompt flows for short. A template-triggered prompt flow is a flow type that appears in the list of available flow types if you have Prompt Builder enabled in your org.
Prompt flows aren’t too different from the flows you already create. What makes them unique is the Add Prompt Instructions action. This action provides data in the form of prompt instructions that’s incorporated into a prompt template in Prompt Builder when the flow is selected as a resource to ground the prompt. Don’t worry, it will all make sense in a bit.
Basic prompt flow building block combo: Get Records-Loop-Add Prompt Instructions
A prompt flow, at its most simplistic build, consists of a Get Records element, a Loop element, and a Prompt Instructions action within the Loop. You essentially need to get data using the Get Records, then for each record found, you add specific information from the record into the prompt template using the Add Prompt Instructions action. That might be all you need to get the data and add it to the prompt template. This is not to say you can’t build pretty fancy in the data gathering in your prompt flows. Of course, you can. I see you overachiever Flownatics out there!
Example scenario: Mochi Cupcakes
Let’s use my Mochi Cupcakes example shown in the video to step through how we use our flow building skills in Prompt Builder.
Mochi Cupcakes is an old-school cupcake store. They don’t do online orders, only orders over the phone. Since the reps work with customers over the phone, they need a very quick way to recap the customer’s recent cupcake orders and, based on past orders, recommend a cupcake order including an over-the-top cupcake and cupcake classes to take, given past enrollments. They can’t afford to put their customer on hold while they figure out this information, so they turned to AI for help. Our solution to this business challenge includes building a prompt flow to ground a Field Generation prompt template.
We’re not going to focus on the entire prompt we built for our Field Generation prompt template. As we built out the prompt template, we determined that we needed information on the regular and over-the-top cupcake flavors, frosting types, and decoration themes, and to get the information about the customer’s past class enrollments, cupcake classes, and class offerings. This data is beyond what we can access via merge fields in Prompt Builder. Prompt flow to the rescue!
As you can see in the video at the 18-minute mark, I step through Mochi’s Suggestive Order and Course prompt flow.
In the Start element of my prompt flow, I specify to use (1) Automatic Inputs so I’m using inputs sent from my prompt template type instead of manually creating my own input variables. In my case, I’m using the (2) Field Generation Template Capability and my object is (3) Contact. Note: The Contact object is key to something we will reference later on in this prompt flow.
The bulk of this flow consists of the basic Get Records, Loop, Add Prompt Instructions combo for getting the cupcake flavors, over-the-top cupcake flavors, frosting types, over-the-top frosting types, decoration themes, over-the-top decoration themes, and cupcake courses.
Since all of these are pretty much the same except for the filter criteria of the Get Records element and what is captured in the Prompt Instructions action, I’ll show you how I retrieved the cupcake courses.
In my Get Records element for cupcake courses, I’m getting all my records from the Course object—no filtering or sorting—and I’m storing all the fields automatically.
Next, I have my Loop element which will loop through each record from my ‘Get Courses’ Get Records element.
Here’s the important ingredient to making this all work with the prompt template: the Add Prompt Instructions action. Notice, in the Prompt Instructions area, I’m using merge fields from my Loop record to gather the course name, course description, and course duration for my prompt template.
I want to gather all the future class offerings for my prompt because I don’t want to recommend any class offerings that have already happened. In this case, I used the Get Records element to get the classes, then a Decision element to determine whether the class was in the future and, if so, for each record from the Get Records collection, I would add that class offering to the prompt template. Again, this still follows the basic Get Records-Loop-Add Prompt Instructions combo with a Decision element thrown into the mix.
Meet $Input, the new global variable
The last portion of my prompt flow is getting the customer’s enrollments using a Get Records element, then using a Decision element to determine whether the flow found any enrollments. If yes, we loop through each record from the Get Records collection and add the past enrollments to the prompt template.
In the Get Enrollments Get Records element, I filtered the records from the Enrollment object using Contact equals to the contact ID passed from Prompt Builder to my prompt flow. Note: The value uses $Input > RelatedEntity > ContactId. $Input is a new global variable. This indicates the input passed from the prompt template. Remember the Contact object I specified in the Start element? That is the Related Entity. After selecting the Related Entity, I select the Contact ID. Check out the 20:06-minute mark in the video where I talk about this in greater detail.
Test and activate your prompt flow
After you build your flow and before activation, test your flow using Debug. One thing I’d like to point out is that the Add Prompt Instructions action behaves like an Assignment element. It takes the contents of that Prompt Instructions box and assigns the value to the output variable prompt ($Output.Prompt).
The prompt flow continues to add data to the Prompt variable each time it’s invoked. As shown in the GIF below, in the very last Add Prompt Instructions element, you may have one massive cumulative prompt like this.
The contents of the Prompt variable are passed from our prompt flow into our prompt template. In other words, that’s how we’re grounding the prompt with data.
After the prompt flow is tested, it’s ready for use so we activate the flow.
Then, back in the prompt template you want the flow to be called, you select the flow from the Resource Picker > Flow.
Pro tips
Activate your prompt flow. Otherwise, it will not appear in the resource picker in Prompt Builder.
Refresh Prompt Builder. If you’re in Prompt Builder before you activated the prompt flow, you’ll need to navigate out of the prompt template and open it again in order for that new flow to show in the resource picker.
Design impactful prompt template actions for your agents
Agents are the way of the future, working together with humans to drive success in the AI era. Your expertise in prompt and flow building will prime you for success, making the creation of prompt template actions an absolute breeze. Once you’ve built your prompt grounded with data from your flow, creating a prompt template agent action is really straightforward!
Just navigate to your agent in Agent Builder, choose the relevant topic, go to This Topic’s Actions, and from the action dropdown, select New > Prompt Template. Choose the prompt as the reference action, then review and update the instruction fields as needed and set your inputs and outputs accordingly, ensuring at least one output is set to ‘Show in conversation’.
Once you’ve added the prompt template agent action, it becomes available in the asset library for reuse across other agents in your Salesforce org. That's what we call working smarter, not harder. And I'm all for that.
Try this at home
I’m sure you can think of examples of how you can flex those Flow skills by building prompt flows to further enrich your prompts with data. Share your creative use cases on social, and don’t forget to tag us or use #AwesomeAdmin. We can’t wait to see what you’ve built!
What are agent quick actions and why should you care? Starting in Spring ’25*, you can now harness the power of your agent actions right to your record pages with an agent shortcut. This new feature streamlines workflows and improves user efficiency by allowing your users to trigger an agent right from a record page, […]
Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Bradley Condon built the […]
As a Salesforce Admin, you’re likely already familiar with Agentforce, Salesforce’s collection of assistive and autonomous artificial intelligence (AI) agents. Agentforce can handle a wide variety of tasks within the Salesforce ecosystem. But what happens when your business relies on external applications? How can you extend Agentforce to integrate with other essential tools? Enter MuleSoft–Salesforce’s […]