构建 Flex 提示模板
学习目标
在本项目中,您将:
- 使用提示生成器创建 Flex 提示模板。
- 创建模板触发的提示流以用于 Flex 提示模板。
开始之前
开始此模块前,请考虑完成下列推荐内容:
简介
提示生成器中的 Flex 提示模板提供了一种通用且高效的方式,可以自动创建 PDF、社交媒体帖子、简报、电子邮件、记录字段等文本,并可以使用 Einstein 生成式 AI 和 LLM(大型语言模型)完成更多内容。与提示生成器中的销售电子邮件或字段生成提示模板不同,Flex 模板没有预定义的入口点。这是什么意思呢?您可以在组织中选择要在模板中使用的任何对象,并在您认为合适的地方应用完成的提示。无论是使用 Apex、流、REST API 还是 Agentforce,Flex 模板都是为满足您的需求而设计的。
在本项目中,您将学习如何在提示生成器中创建和测试 Flex 提示模板。您还将了解如何使用流来改进提示响应并有效地处理大型数据集。您的任务是为一个受欢迎的度假胜地——Coral Cloud 度假村设计一份简报,突出来宾住宿期间酒店将举行的活动。
注册一个含 Einstein AI 的自定义 Playground
为了完成这个项目,您需要一个专门的、限时的自定义 Playground,其中包含 Einstein AI 和我们的示例数据。
- 勾选单元开头的 I can receive a password email(我可以接收密码邮件)复选框(如果还没勾选的话)。
- 单击 Create Playground(创建 Playground)。
- 根据提示操作。
- 记住组织的到期日期,并在此日期之前完成这个徽章。
在设置中启用 Einstein
- 如果没打开启用了 Einstein AI 的试用组织,请向下滚动到 Challenge(挑战)部分,单击 Launch(启动)打开。
- 单击
并单击 Setup(设置)。Setup(设置)页面在新选项卡中打开。
- 在 Quick Find(快速查找)框中,输入
einstein setup
(Einstein 设置),单击 Einstein Setup(Einstein 设置)。
- 单击切换开关打开 Einstein。如果已完成“快速入门:Agentforce 项目”,则可能已打开。
- 刷新浏览器窗口。启用了 Einstein 后,将显示新的管理员设置。
添加体验数据
在开始使用提示生成器之前,让我们创建两个新的度假村活动作为测试数据。
首先,您需要创建一个卡拉 OK 之夜。
- 在自定义 Playground 中,单击 App Launcher(应用程序启动器)
并在搜索栏中输入
Experience
(体验)。
- 单击 Experiences(体验)。
- 单击 New(新建)。
- Experience Name(体验名称)输入
Family Karaoke Night
(家庭卡拉 OK 之夜)。
- 在 Activity Level(活动级别)处,选择 Low(低)。
- 在 Capacity(容纳人数)处,输入
50
。
- Default Start Time(默认开始时间)选择 6:00 PM(下午 6:00)。
- 在 Description(描述)处,粘贴下列文本:
Join us for Family Karaoke Night and sing your heart out with your loved ones! It's a fun-filled evening where you can showcase your talent, laugh together, and create unforgettable memories.
- 在 Duration(持续时间)处,输入
2
。
- 在 Location(位置)处,输入
Melody Lounge
(旋律休息室)。
- 在 Type(类型)处,选择 Family & Kids’ Activities(家庭和儿童活动)。
- 单击 Save & New(保存并新建)。
接下来,创建一个瑜伽活动。
- 在 Experience Name(体验名称)处,输入
Sunrise Yoga
(日出瑜伽)。
- 在 Activity Level(活动级别)处,选择 Medium(中)。
- 在 Capacity(容纳人数)处,输入
35
。
- Default Start Time(默认开始时间)选择 6:00 PM(上午 7:00)。
-
在 Description(描述)处,粘贴下列文本:
Start your day with Sunrise Yoga on the beach, where you can stretch under the warm morning sun and listen to the soothing sound of the waves. It's the perfect way to feel refreshed and ready for a fun day ahead!
- 在 Duration(持续时间)处,输入
1
。
- 在 Location(位置)处,输入
Cocoa Shore
(可可海岸)。
- 在 Type(类型)处,选择 Fitness & Exercise(健身与锻炼)。
- 单击 Save(保存)。
创建 Flex 模板
数据准备好之后,是时候创建一个新的 Flex 提示模板了。这一步为您的提示奠定了基础。在您自己的项目中设置 Flex 模板时,请仔细选择 API 名称,因为它们将用在使用 Apex 或流的模板中。
- 单击
并单击 Setup(设置)。
- 在 Quick Find(快速查找)框中,输入
prompt
(提示),然后单击 Prompt Builder(提示生成器)。
- 单击 New Prompt Template(新建提示模板)。
- 做出如下选择,完成模版设置:
- Prompt Template Type(提示模板类型):Flex
- Prompt Template Name(提示模板名称):
New Guest Newsletter
(新来宾简报)
- API Name(API 名称):
New_Guest_Newsletter
- Template Description(模板描述):
Newsletter for incoming resort guests.
(为即将到来的度假村来宾提供的简报)。
- Prompt Template Type(提示模板类型):Flex
- 对于 Flex 模板,您最多可以添加五种资源。在 Define Sources(定义来源)下,通过对象类型添加两种资源。对于第一个,输入:
- Name(名称):
Reservation
(预约)
- API Name(API 名称):
Reservation
(预约)
- Source Type(来源类型):Object(对象)
- Object(对象):External Reservation(外部预约)
- Name(名称):
- 要添加第二个,单击 Add Resources(添加资源),然后输入:
- Name(名称):
Experience
(体验)
- API Name(API 名称):
Experience
(体验)
- Source Type(来源类型):Object(对象)
- Object(对象):Experience(体验)
- Name(名称):
- 单击 Next(下一步)。Prompt(提示)工作区打开。
创建提示
好极了!针对这个场景,我们提供了一个提示来帮助您开始创建度假村简报。您将注意到,它包含针对来宾预约信息和度假村体验详细信息的合并字段。如果您有兴趣了解什么样的提示才算是好的提示,请查看提示基础知识徽章。
将下列文本粘贴到 Prompt(提示)工作区:
You're the Director of Fun at Coral Cloud Resorts writing a newsletter to welcome {the new guest} 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: {Check-in Date} Check Out: {Check-out Date} Room Selection: {Room Type} Include a bulleted list of the experiences available during the guest’s stay, including the description and the locations. The experiences are as follows: Experience Name: {Experience Name} Experience Location: {Experience Location} Experience Details: {Experience Details} 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.
添加合并字段
在新的提示中,合并字段(用大括号括起来的文本)添加了上下文。在提示生成器中,您可以通过从 Resource(资源)选项列表中选择资源,轻松地合并来自 CRM、Data Cloud 或外部来源(通过 Data Cloud)的相关数据。接下来就来完成。
- 在提示中找到文本 {the new guest} 并将其删除。如要将该文本替换为正确的合并字段,单击 Insert Resource(插入资源),然后选择 Reservation(预约) > External Guest(外部客户)> First Name(名字)。
- 在提示中找到文本 {Check-in Date} 并将其删除。单击 Insert Resource(插入资源),然后选择 Reservation(预约) > Check-in Date(入住日期)。
- 在提示中找到文本 {Check-out Date} 并将其删除。单击 Insert Resource(插入资源),然后选择 Reservation(预约) > Check-out Date(退房日期)。
- 在提示中找到文本 {Room Type} 并将其删除。单击 Insert Resource(插入资源),然后选择 Reservation(预约) > Room Type(房型)。
- 在提示中找到文本 {Experience Name} 并将其删除。单击 Insert Resource(插入资源),然后选择 Experience(体验) > Experience Name(体验名称)。
- 在提示中找到文本 {Experience Location} 并将其删除。单击 Insert Resource(插入资源),然后选择 Experience(体验) > Location(位置)。
- 在提示中找到文本 {Experience Details} 并将其删除。单击 Insert Resource(插入资源),然后选择 Experience(体验) > Description(描述)。
- 在 Models(模型)下选择 OpenAI GPT 4 Omni Mini。
- 单击 Save(保存)。
您的提示模板应为:
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.(您是 Coral Cloud 度假村的娱乐活动总监,正在撰写一封欢迎简报:Input:Reservation.External_Guest__r.First_Name__c,并告知他们在入住期间即将开展的活动。)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(入住:Input:Reservation.Check_in_Date__c)
Check Out: Input:Reservation.Check_out_Date__c(退房:Input:Reservation.Check_out_Date__c)
Room Selection: Input:Reservation.Room_Type__c(房型选择: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:(这些体验如下:)
Experience Name(体验名称):Input:Experience.Name
Experience Location(体验地点):Input:Experience.Location__c
Experience Details(体验详细信息):Input:Experience.Description__c
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.(现在创建该简报。)
在提示生成器中,应该类似于下面这样:
做得好!您的提示模板已完成,可以进行测试了。
测试提示
让我们使用 Preview(预览)功能,用 Experience(体验)和 Reservation(预约)这两个字段来测试数据。在 Preview(预览)中,您可以选择为您的提示模板测试数据,看看生成的响应是什么样子。
- 单击 Preview(预览)按钮打开 Preview Settings(预览设置)。
- 在 Reservation(预约)字段中,键入
er
并选择任何预订。
- 在 Experience(体验)字段中,键入
Sun
并选择Sunrise Yoga
(日出瑜伽)。
- 单击 Preview(预览)并查看您的提示模板的输出。
在 Generated Response(生成的响应)部分中,您可以查看 Reservation(预约)和 Experience(体验)数据如何为客户提供个性化新闻简报。但是,度假村会举行多种活动。您希望简报可以分享多个活动。在下一步中,了解如何使用流添加其他内容——在本例中是其他客户体验。