Skip to main content
Join us at TDX in San Francisco or on Salesforce+ on March 5-6 for the Developer Conference for the AI Agent Era. Register now.

Add a Flow to Your Prompt Template

Coral Cloud Resorts often has than one event during a guest’s stay. Next, you 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 Setup 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 has two options: Start from Scratch and Use a Template.

  1. For the type, select Template-Triggered Prompt Flow, and click Create.
    The Flow Builder Menu displays multiple flow types.

Flow Builder opens.

  1. Leave the input type Manual Inputs.

Select Input Type Menu with options for manual or automatic inputs.

  1. Select Toggle Toolbox.

The Flow Builder canvas with the Toggle Toolbox button in the toolbar.

  1. Click New Resource and enter the following details:
    • Resource Type: Variable
    • API Name: Reservation
    • Data Type: Record
    • Object: External Reservation
    • Available for input: Selected
  2. Click Done.

The New Resource screen corresponding to the preceding instructions.

  1. Click New Resource again and enter the following details:
    • Resource Type: Variable
    • API Name: Experience
    • Data Type: Record
    • Object: Experience
    • Available for input: Selected
  2. Click Done.
  3. Click Save to save the flow.
  4. The Save the flow window appears. This is where you assign the flow details:
    • Flow Label: Get Experience Newsletter Data
    • Flow API Name: Get_Experience_Newsletter_Data
    • Description: Filter all guest experience data to return to guests.
  5. Click Save.

Add Elements to the Prompt Flow

  1. Click Add element “” between Start and End.
  2. In the Add Element box, type Get and select the element Get Records to retrieve and store the experiences in a collection.
  3. For Label, enter Guest Experience, and keep Guest_Experience for the API Name.
  4. For Description, enter Get all experience data.
  5. For Object, select Experience. 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. For Sort Order, keep Not Sorted.
  8. For How Many Records to Store, select All records.
  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, click Add element “” after the Get Records element.
  2. Add a Loop element by typing Loop and selecting it.
  3. For Label, enter Loop Experiences and keep Loop_Experiences for the API Name.
  4. For Description, enter Loop through the collection of guest experiences.
  5. For Collection Variable, 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. In the For Each path of the Loop element, click Add element “”.
  2. Type add and select the Add Prompt Instructions element to add to the flow.
  3. For Label, enter Send Experience Details to the Prompt Template and keep Send_Experience_Details_to_the_Prompt_Template in the API Name field.
  4. For Description, enter Add all qualifying experience details to the prompt instructions.
  5. For Prompt Instructions, paste the following text (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.
    The final Get Experience Newsletter Data flow corresponding to the preceding instructions.

Add the Flow to Your Prompt Template

Now that your flow is activated in Flow Builder, it’s ready to use in Prompt Builder.

  1. Exit Flow Builder and return to Setup.
  2. In the Quick Find box, enter prompt, then click Prompt Builder.
  3. Select the New Guest Newsletter prompt template.
  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 the Resource field and selecting Flows > Get Experience Newsletter Data.
  2. Click Save As, then Save as a New Version.

Your prompt template should read:.

You're the Director of Fun at Coral Cloud Resorts writing a newsletter to welcome Input:Reservation.External_Guest__r.First_Name__c and inform them of upcoming activities during their stay. The purpose of the newsletter is to get guests excited about staying at the resort. When I ask you to create the newsletter, you must strictly follow my instructions below.

Instructions:

Introduce the resort in a newsletter no longer than three paragraphs.

Inform the guests about their reservation using the following details:

Check In: Input:Reservation.Check_in_Date__c

Check Out: Input:Reservation.Check_out_Date__c

Room Selection: Input:Reservation.Room_Type__c

Include a bulleted list of the experiences available during guests stay, including the description and the locations. The experiences are as follows:

Flow:Get_Experience_Newsletter_Data.Prompt

Use clear and straightforward language using the active voice and strictly avoiding the use of filler words and phrases and redundant language. Be conversational.

Do not attribute any negative traits in the summary.

End with a call to action for readers to look at our website for these offers.

Now create the newsletter.

In Prompt Builder, it looks like this:

Flex prompt template corresponding to the preceding text.

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. Review the output of your prompt template. Now the response includes the yoga experience as well as the karaoke night.
  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