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
- Click and click Setup. The Setup page opens in a new tab.
- In the Quick Find box, enter
flows
, then click Flows.
- Click New Flow, Start From Scratch, then Next.
- For the type, select Template-Triggered Prompt Flow, and click Create.
Flow Builder opens.
- Leave the input type Manual Inputs.
- Select Toggle Toolbox.
- Click New Resource and enter the following details:
- Resource Type: Variable
- API Name:
Reservation
- Data Type: Record
- Object:
External Reservation
- Available for input: Checked
- Resource Type: Variable
- Click Done.
- Click New Resource again and enter the following details:
- Resource Type: Variable
- API Name:
Experience
- Data Type: Record
- Object:
Experience
- Available for input: Checked
- Resource Type: Variable
- Click Done.
- Click Save to save the flow.
- 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.
- Flow Label:
- Click Save.
Add Elements to the Prompt Flow
- Click the plus icon () between Start and End.
- In the Add Element box, type
Get Records
and select the element Get Records to retrieve and store the experiences in a collection.
- Enter
Guest Experience
in the Label field, andGuest_Experience
for the API Name.
- In the description field add,
Get all experience data
.
- Select Experience from the Object field. The newsletter needs to include only the events that guests can participate in during their stay.
- In the Condition Requirements, select None - Get All Experience Records.
- In the Sort Order drop down, select Not Sorted.
- Select All records in the How Many Records to Store.
- Click Save.
Currently all of the experiences are stored in a collection. To look at each item individually let’s add a loop.
- Back in the flow, click the plus icon () after the Get Records element.
- Add a Loop element by typing
Loop
and selecting it.
- Enter
Loop Experiences
in the Label field andLoop_Experiences
for the API Name field.
- Enter
Loop through the collection of guest experiences.
in the Description field.
- In the Collection Variable field, select Experiences from Guest Experience.
- 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.
- After the For Each path of the Loop element, click the plus icon (). Type
add
and select the Add Prompt Instructions element to add to the flow.
- Enter
Send Experience Details to the Prompt Template
in the label field andSend_Experience_Details_to_the_Prompt_Template
in the API Name field.
- Enter
Add all qualifying experience details to the prompt instructions.
in the Description field.
- 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})
- Click Save, then Activate.
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.
- Exit Flow Builder, then click Setup. Click and click Setup.
- In the Quick Find box, enter
prompt
, then click Prompt Builder.
- Select the prompt template, New Guest Newsletter.
- 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
- Then, replace the text by clicking in the Resource field, and selecting Flows > Get Experience Newsletter Data.
- Click Save As, then Save as a New Version.
Your prompt template should look like this.
Test the Prompt
- In the Reservation field type,
er
. Select any reservation.
- In the Experience field type,
Family
. Select Family Karaoke Night.
- Click Preview.
- Take a look at the output of your prompt template.
- 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.