Unleashing productivity: Master prompt templates with flow tools

Unleashing Productivity: Master Prompt Templates with Flow Tools

By

Prompt Builder became generally available on February 29, just over two months ago. Since then, we’ve seen a lot of Salesforce Admins start to experiment and come up with a wide variety of use cases to leverage it. From summarizing records to generating points of view and even creating business-context rich emails, there are a tremendous amount of use cases that Prompt Builder can help solve for.

In my previous write-up of Prompt Builder, I focused on the importance of grounding prompts and prompt templates with your rich CRM data. This can be easily achieved using standard tools such as merge fields (from objects), flows, and Apex classes. Incorporating these prompt templates into a variety of template types such as emails, Field Generation, and even Flex templates is also easy.

The current challenge

While the out-of-the-box user experience for Prompt Builder is great, it often takes too many clicks to get a generative artificial intelligence (GenAI) response, specifically for Field Generation template types. Admins and users looking to quickly share the value that GenAI could have at their organizations might foresee this as a challenge, leading to negatively impacting adoption and usage of Prompt Builder.

Below is a brief video that outlines what the current user experience is like for using Prompt Builder when attempting to update a field.

To help address this challenge, and also inspire admins to learn how to reduce the number of clicks needed to get a GenAI response back from a large language model (LLM), this write-up focuses on a few techniques of seamlessly integrating Prompt Builder to enhance business processes, thereby creating efficiencies within existing workflows.

The opportunity

A hidden gem of Prompt Builder is the fact that prompt templates can now be called as actions throughout the Salesforce Platform. This means admins can now easily invoke them using standard flows! Through screen flows or even autolaunched flows, admins can invoke prompt templates without needing users to manually obtain a GenAI response. Other options for invoking prompt templates include using the Metadata API, Connect API, or even Apex classes. Find more details in this documentation.

Let’s dive into a few examples of how you can invoke prompt templates using flows.

Dynamic Action

Use case

Your key account has many opportunities associated to it; most of them are closed and some of them are open. You need a quick and easy way to get a list of these opportunities along with the pertinent details associated to them for an upcoming account review with them. Users should be able to get this information without having to click into the various tabs on the Lightning page.

Solution

Because Dynamic Actions are easily available on a record’s Highlight’s panel, they are almost always “pinned” to the Lightning page layout. This means that they are almost always available on a record page no matter where a user navigates while on it. Because of this modularized behavior, the Highlights panel offers an opportunity for admins to place a button allowing users to call on a prompt template quite easily.

Here are the detailed steps for this solution.

  1. Create a prompt template in Prompt Builder.
  2. Create a screen flow.
    • The Record ID will be provided by the context of where the screen flow is run.
    • The Record ID obtained will be passed as an input into the prompt template (being referenced as an Invocable Action in the flow).
    • The response from the LLM will be displayed to the user through a Screen element. Best practice recommendation: Because these responses are generated through an LLM, it’s best to place a message within the Screen element informing users that they should review the responses for accuracy.
    • The response will be saved to the record using a standard Update Records operation. Best practice recommendation: Since GenAI will provide responses based on your data quality in conjunction with the instructions provided in your prompt templates, it’s recommended to insert a timestamp of when the summary was generated by the LLM. This will ensure that users are fully aware of how “fresh” the summary is.
  3. Create an Action on the object which will call on the screen flow (created in the previous step).
  4. Place the Dynamic Action on the object’s Lightning page.

Menu of prompt templates

Use case

While the above example was a great starting point for integrating prompt templates with flows, it still poses a risk to adoption. In the videos above, you may have noticed that we had six individual fields in total on the Account object page, each providing summaries for an account’s:

  • Cases
  • Opportunities
  • Activities
  • Orders
  • Invoices
  • Holistic summary (that combined all of the above)

Would this mean that we would need to create six separate Dynamic Actions and place them on the Lightning layout? This would present a few different challenges for admins. First, you would need to spend an inordinate amount of time creating separate Dynamic Actions for every field where you’d like a GenAI response. And second, from a maintenance standpoint, it would be less than ideal to update the Dynamic Actions when business processes evolve.

Solution

Luckily, we have the flexibility and creativity of using flows to address this use case! Let’s learn more about how to make this a better user experience. The details of this solution are very similar to the previous solution, with a few minor differences outlined below.

  1. Create a prompt template in Prompt Builder.
  2. Create a screen flow.
    • The Record ID will be provided by the context of where the screen flow is run.
    • A screen is presented to the user asking them which prompt template they’d like to invoke, preferably through a radio button selection.
    • Based on the user’s selected choice, a Decision element will be used to branch out separate outcomes. Each branch will associate a separate Invocable Action (of a prompt template) that will correspond to the choice made by the user.
    • The response from the LLM will be displayed to the user through a Screen element. Best practice recommendation: Because these responses are generated through an LLM, it’s best to place a message within the Screen element informing users that they should review the responses for accuracy.
    • Just as with the previous solution, the GenAI response will be saved to the record using a standard Update Records operation. Best practice recommendation: Since GenAI will provide responses based on your data quality in conjunction with the instructions provided in your prompt templates, it’s recommended to insert a timestamp of when the summary was generated by the LLM. This will ensure that users are fully aware of how “fresh” the summary is.
  3. Create an Action on the object which will call on the screen flow (created in the previous step).
  4. Place the Dynamic Action on the object’s Lightning page.

Autolaunched screen flow

Use case

Some users may wish to be presented with a GenAI response immediately upon loading a record page without clicking anywhere on the page. This can be especially helpful for cases where speed of delivered information is paramount to a user’s productivity; clicking a button wouldn’t be an option for such scenarios.

Solution

Once again, use the power of flows to solve for this requirement. The details of this solution are similar to the previous two.

  1. Create a prompt template in Prompt Builder.
  2. Create a screen flow.
    • The Record ID will be provided by the context of where the screen flow is run.
    • The Record ID obtained will be passed as an input into the prompt template (being referenced as an Invocable Action in the flow).
    • The response from the LLM will be displayed to the user through a Screen element. Best practice recommendations: Because these responses are generated through an LLM, it’s best to place a message within the Screen element informing users that they should review the responses for accuracy. Also, since GenAI will provide responses based on your data quality in conjunction with the instructions provided in your prompt templates, it’s recommended to insert a timestamp of when the summary was generated by the LLM. This will ensure that users are fully aware of how “fresh” the summary is.
  3. In Lightning App Builder (on the record page), drop a Flow component onto the canvas and associate your screen flow to the component. Ensure that the Pass all field values from the record into this flow variable checkbox is selected.

Pro tip: As a starting point, admins can add a component visibility filter on the Flow component to render for certain types of records, such as Tier 1 Accounts or Escalated Cases.

While this technique is great for providing immediate value and benefit to users, admins must exercise caution when implementing it. Because this solution would automatically launch a prompt template on page load, it would also automatically consume your quota of Einstein Requests in accordance with your org’s allocation. More details on that here.

Integrate Prompt Builder into your workflows today

My personal favorite solution is option 2: menu of prompt templates. It gives admins the flexibility of adding, removing, or updating the choices of which prompt templates they’d like to offer their users based on the needs of their organization, all without sacrificing on how users can perform their day-to-day functions in Salesforce.

As you can imagine, the possibilities of solving for your users’ needs are endless with the flexibility of embedding GenAI responses within an existing workflow. As an admin, it’s strongly recommended that you review and evaluate existing business processes to understand where in a process you could possibly embed GenAI without cutting back on your users’ productivity or experience. You may end up using one, multiple, or all of the above solutions!

Resources

A Salesforce Admin's Guide to TrailblazerDX 2024.

A Salesforce Admin’s Guide to TrailblazerDX 2024

The Trailblazer community is coming back together on March 6-7, 2024, in San Francisco and on Salesforce+ for TrailblazerDX 2024—join us! Generative artificial intelligence (AI) is revolutionizing application development, creating the most significant shift and opportunities for both admins and developers in decades. At TDX, you’ll learn to supercharge user productivity, automate business processes, and […]

READ MORE
Be Release Ready Spring '24 | The Ultimate Guide to Prompt Builder.

The Ultimate Guide to Prompt Builder | Spring ’24

Artificial intelligence (AI) is not a new concept to Salesforce or to Salesforce Admins. Over the years, Salesforce has empowered admins with a user-friendly interface for the setup and configuration of predictive AI features such as Opportunity Scoring, Lead Scoring, Einstein Bots, and more. The introduction of generative AI in Salesforce brings even more possibilities […]

READ MORE
10 Important Takeaways for Salesforce Admins from 2023

10 Important Takeaways for Salesforce Admins from 2023

As we approach the end of 2023, it’s the perfect time to reflect on what we’ve learned as a Salesforce Admin community and to prepare for the exciting year ahead. In this blog post, we’ll recap essential insights that will help you walk away from this year ready to tackle 2024. Let’s dive into our […]

READ MORE