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
- 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: Selected
- 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: Selected
- 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:
- 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 Add element
between Start and End.
- In the Add Element box, type
Get
and select the element Get Records to retrieve and store the experiences in a collection.
- For Label, enter
Guest Experience
, and keepGuest_Experience
for the API Name.
- For Description, enter
Get all experience data
.
- For Object, select Experience. 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.
- For Sort Order, keep Not Sorted.
- For How Many Records to Store, select All records.
- 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 Add element
after the Get Records element.
- Add a Loop element by typing
Loop
and selecting it.
- For Label, enter
Loop Experiences
and keepLoop_Experiences
for the API Name.
- For Description, enter
Loop through the collection of guest experiences.
- For Collection Variable, 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.
- In the For Each path of the Loop element, click Add element
.
- Type
add
and select the Add Prompt Instructions element to add to the flow.
- For Label, enter
Send Experience Details to the Prompt Template
and keepSend_Experience_Details_to_the_Prompt_Template
in the API Name field.
- For Description, enter
Add all qualifying experience details to the prompt instructions.
- 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})
- Click Save, then Activate.
Add the Flow to Your Prompt Template
Now that your flow is activated in Flow Builder, it’s ready to use in Prompt Builder.
- Exit Flow Builder and return to Setup.
- In the Quick Find box, enter
prompt
, then click Prompt Builder.
- Select the New Guest Newsletter prompt template.
- 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 the Resource field and selecting Flows > Get Experience Newsletter Data.
- 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:
Test the Prompt
- In the Reservation field type,
er
. Select any reservation.
- In the Experience field type,
Family
. Select Family Karaoke Night.
- Click Preview.
- Review the output of your prompt template. Now the response includes the yoga experience as well as the karaoke night.
- 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.