Skip to main content
Join Trailblazers for Dreamforce 2024 in San Francisco or on Salesforce+ from September 17-19. Register now

Add a Flow to Your Prompt Template

In the resort, often more than one event happens during a guest’s stay. Next, create a flow to include all the experiences that guests can participate in during their stay. To do this, you create a Template-Triggered Prompt Flow.

Create a Template-Triggered Prompt Flow

  1. Click gear icon and click Setup. The Setup page opens in a new tab.
  2. In the Quick Find box, enter flows, then click Flows.
  3. Click New Flow, Start From Scratch, then Next.

Flow Builder menu with new flow options. Start from Scratch is highlighted.

  1. For the type, select Template-Triggered Prompt Flow, and click Create.

Flow Builder Menu with flows options. Template-Triggered Prompt Flow is highlighted.

Flow Builder opens. Select the prompt template New Guest Newsletter that you created in Prompt Builder. You’ll also see the input data types you selected in Prompt Builder.

In Flow Builder, the Select Prompt Template Type menu is open. Highlighting the New Guest Newsletter prompt template.

  1. Click Save.
  2. The Save the flow window appears. This is where you assign the flow details to the model. Enter the following into each field:
    • Flow Label: Get Experience Newsletter Data
    • Flow API Name: Get_Experience_Newsletter_Data
    • Description: Filter all guest experience data to return to guests.
  3. Click Save.

Add Elements to the Prompt Flow

  1. Hover over the open circle between Start and End, and click the plus icon.
  2. In the Add Element box, type Get Records and select the element Get Records to retrieve and store the experiences in a collection.
  3. Enter Guest Experience in the Label field, and Guest_Experience for the API Name.
  4. In the description field add, Get allexperience data.
  5. Select Experience from the Object field. The newsletter needs to include only the events that guests can participate in during their stay.
  6. In the Condition Requirements, select None - Get All Experience Records.
  7. In the Sort Order drop down, select Not Sorted.
  8. Select All records in the How Many Records to Store.
  9. Click Save.

Currently all of the experiences are stored in a collection. To look at each item individually let’s add a loop.

  1. Back in the flow, hover over the open circle after the Get Records element and click the plus sign.
  2. Add a Loop element by typing Loop and selecting it.
  3. Enter Loop Experiences in the Label field and Loop_Experiences for the API Name field.
  4. Enter Loop through the collection of guest experiences. in the Description field.
  5. In the Collection Variable field, select Experiences from Guest Experience.
  6. Click Save.

Template-triggered flows offer a unique capability: creating prompt instructions. These instructions gather and pass data and text from Flow Builder to Prompt Builder. In the next step, you use prompt instructions to format all of the experience details to send to Prompt Builder and activate the flow to use within Prompt Builder.

  1. After the For Each path of the Loop element, hover over the open circle and click the plus sign. Type add and select the Add Prompt Instructions element to add to the flow.
  2. Enter Send Experience Details to the Prompt Template in the label field and Send_Experience_Details_to_the_Prompt_Template in the API Name field.
  3. Enter Add all qualifying experience details to the prompt instructions. in the Description field.
  4. Paste the following text in the Prompt Instructions field (below the search box labeled Insert a resource…).
(Experience Name: {!Loop_Experiences.Name},
 Experience Location:{!Loop_Experiences.Location__c} ,
 Experience Details: {!Loop_Experiences.Description__c})
  1. Click Save, then Activate.

Flow Builder displaying the final Get Event Newsletter Data Flow.

Add the Flow to Your Prompt Template

Since your flow has been activated in Flow Builder, it’s now ready to use in Prompt Builder.

  1. Exit Flow Builder, then click Setup. Click gear icon and click Setup.
  2. In the Quick Find box, enter prompt, then click Prompt Builder.
  3. Select the prompt template, New Guest Newsletter.
  4. Let’s replace the existing Experience merge fields with the flow. First, select and delete the following text:
    Experience Name: Input:Experience.Name
    Experience Location: Input:Experience.Location__c
    Experience Details: Input:Experience.Description__c
  1. Then, replace the text by clicking in the Resource field, and selecting Flows > Get Experience Newsletter Data.
  2. Click Save.

Your prompt template should look like this.

Flex prompt template with the flow merge field replacing the three deleted merge fields.

Test the Prompt

  1. In the Reservation field type, er. Select any reservation.
  2. In the Experience field type, Family. Select Family Karaoke Night.
  3. Click Preview.
  4. Take a look at the output of your prompt template.
  5. Click Activate.

Great work! You've quickly learned how to craft a prompt template tailored to your needs. By incorporating flows, you've made your templates even more user-friendly for everyone. Keep exploring Prompt Builder to uncover more creative ways to automate text generation.

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback