

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 将 Amazon Lex 自动程序添加到 Amazon Connect
<a name="amazon-lex"></a>

**重要**  
**终止支持通知**：2025年9月15日， AWS 我们将停止对Amazon Lex V1的支持。2025 年 9 月 15 日之后，您将无法再访问 Amazon Lex V1 控制台或 Amazon Lex V1 资源。要了解如何迁移到 Amazon Lex V2，请参阅[迁移机器人](https://docs.aws.amazon.com/lex/latest/dg/migrate.html)。

在本文中，我们将指导您完成将 Amazon Lex 自动程序添加到 Amazon Connect 的步骤。

借助 Amazon Lex，您可以建立对客户来说感觉很自然的对话互动（自动程序）。在 Amazon Connect 流中使用 Amazon Connect 中的 Amazon Lex 自动程序时，还可以捕获客户输入的数字，即客户在数字键盘上输入的数字。这样，客户可以选择他们要如何输入敏感信息（如账号）。

要按本演练进行操作，您需要以下各项：
+ 一个活跃的 AWS 账户。
+ 一个 Amazon Connect 实例 

**提示**  
您还可以使用 Amazon Lex 为 Amazon Connect 聊天提供交互式消息。交互式消息包含丰富的消息，提供提示和预置的显示选项，客户可以从中选择。这些消息由 Amazon Lex 提供支持，并使用 Lambda 通过 Amazon Lex 进行配置。有关更多信息，请参阅 [在聊天中为客户添加 Amazon Lex 互动消息](interactive-messages.md)。

## 创建 Amazon Lex 自动程序
<a name="lex-bot-create"></a>

在此步骤中，您将创建一个自定义自动程序，以演示按下或说出操作与 Amazon Connect 的集成。自动程序提示呼叫方按下或说出与要完成任务的菜单选项相匹配的数字。在这种情况下，输入的目的是检查账户余额。

------
#### [ Amazon Lex ]

1. 打开 [Amazon Lex 控制台](https://console.aws.amazon.com/lexv2/home)。

1. 选择**创建自动程序**。

1. 在**配置自动程序设置**页面，选择**创建 - 创建空白自动程序**并提供以下信息：
   + **机器人名称** — 在本演练中，请命名机器人**AccountBalance**。
   + **IAM 权限** - 如果您已创建角色，请选择一个角色。否则，请选择**创建具有基本 Amazon Lex 权限的角色**。
   + **COPPA** - 选择自动程序是否符合《儿童在线隐私保护法案》的要求。
   + **会话超时** - 选择自动程序在结束会话之前需等待多长时间才能获得呼叫方输入。

1. 选择**下一步**。

1. 提供语言和语音的特定信息：
   + **语言** - 从 [Amazon Lex 支持的语言和区域](https://docs.aws.amazon.com/lexv2/latest/dg/how-languages.html)列表中选择语言和区域。
   + **语音交互** - 为您的自动程序选择对呼叫方说话时要使用的语音。Amazon Connect 的默认声音是 Joanna。

1. 选择**完成**。 AccountBalance 机器人已创建，并显示 “**意图**” 页面。

------
#### [ Amazon Lex (Classic) ]

1. 打开 [Amazon Lex 控制台](https://console.aws.amazon.com/lex/)。

1. 如果这是您第一次创建自动程序，请选择**开始**。否则，依次选择**自动程序、创建**。

1. 在**创建自动程序**页面，选择**自定义自动程序**并提供以下信息：
   + **机器人名称** — 在本演练中，请命名机器人**AccountBalance**。
   + **输出语音** - 为您的自动程序选择对呼叫方说话时要使用的语音。Amazon Connect 的默认声音是 Joanna。
   + **会话超时** - 选择自动程序在结束会话之前需等待多长时间才能获得呼叫方输入。
   + **COPPA** - 选择自动程序是否符合《儿童在线隐私保护法案》的要求。

1. 选择**创建**。

------

## 配置 Amazon Lex 自动程序
<a name="lex-bot-configure"></a>

在此步骤中，您将通过提供目的、示例话语、输入槽和错误处理，以确定自动程序如何对客户进行响应。

在本示例中，您将为自动程序配置两个目的：一个是查找账户信息，另一个是与座席交谈。

### 创建 AccountLookup 意图
<a name="lex-bot-create-account-lookup-intent"></a>

------
#### [ Amazon Lex ]

1. 创建自动程序后，您将进入 Amazon Lex 控制台的**意图**页面。如果你不在那里，你可以通过选择 B **ots**、、**Bot 版本**AccountBalance**、**草稿版本****、**Intents** 来实现目标。选择**添加意图**、**添加空意图**。

1. 在 “**意图名称**” 框中输入**AccountLookup**。

1. 向下滚动页面至**示例言语**。在此步骤中，您输入允许客户表达意图的话语。 AccountLookup 输入以下言语，然后在每个言语后面选择**添加言语**。
   + **查看我的账户余额**
   + **第一：这会将 “一个**” 的说法或按下 “1” 的键盘分配给意图。**AccountLookup**

   下图显示了在**示例言语**部分添加言语的位置。  
![\[“意图”页面的示例言语部分。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lexv2-enter-utterances.png)

1. 滚动到**槽值**部分，然后选择**添加槽值**。按如下说明完成操作：

   1. **此意图为必需的** = 已选中。

   1. **姓名** = **AccountNumber**。

   1. **槽值类型** = **AMAZON.Number**。

   1. **提示** = 接听电话时要说的文本。例如，要求呼叫方使用小键盘输入其账号：**请使用按键式小键盘输入您的账号**。选择**添加**。

   下图显示了已完成的**添加槽值**部分。  
![\[“意图”页面的添加槽值部分。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lexv2-add-slots.png)

1. 滚动到**关闭响应**部分。添加自动程序要对客户说的一条信息。例如，**您的账户余额为 \$11,234.56**。（在本演练中，我们不会真正获取数据，而现实中您要这样做。）

   下图显示了已完成的**关闭响应**部分。  
![\[“意图”页面的关闭响应部分。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lexv2-response1.png)

1. 选择**保存意图**。

------
#### [ Amazon Lex (Classic) ]

1. 在 Amazon Lex 控制台中，选择**意图**旁边的 **\$1** 图标，然后选择**创建新意图**。

1. 命名意图**AccountLookup**。

1. 添加示例言语，如*检查我的账户余额*，然后选择 **\$1** 图标。

1. 添加另一个话语，例如*一*并选择 **\$1** 图标。这会将 “一个” 的说法或按下 “1” 的键盘分配给意图。**AccountLookup**
**提示**  
您必须在自动程序中添加言语“一”，而不是数字“1”。这是因为 Amazon Lex 不直接支持数字输入。为了解决这个问题，在本演练后面，您将使用数字输入与从流调用的 Lex 自动程序进行交互。

1. 在 “**老虎机**” 下，添加一个名为的插槽**AccountNumber**。

   下图显示了页面上**槽值**部分的位置。  
![\[“意图”页面的槽值部分。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lex-slots.png)

1. 对于**槽类型**，使用下拉列表选择 **AMAZON.NUMBER**。

1. 对于**提示**，添加接听电话时要说的文本。例如，要求呼叫方使用小键盘输入其账号：*请使用按键式小键盘输入您的账号*。

1. 选择 \$1 图标。

1. 确保选中**必需**复选框。

1. 在**响应**部分，添加自动程序要对客户说的一条信息。例如，**您的账户余额为 \$11,234.56**。

1. 选择 **Save Intent (保存目的)**。

------

### 创建 SpeakToAgent 意图
<a name="lex-bot-create-speaktoagent-intent"></a>

------
#### [ Amazon Lex ]

1. 导航至**意图**页面：选择**返回意图列表**。

1. 选择**添加意图**、**添加空意图**。

1. 在 “**意图名称**” 框中输入 **SpeakToAgent**，然后选择**添加**。

1. 向下滚动至**示例言语**部分。输入以下话语，让客户能够表达意图： SpeakToAgent 
   + **与座席交谈**
   + **二**

1. 向下滚动至**关闭响应**部分。添加自动程序要对客户说的一条信息。例如，**好的，座席将马上与您联系**。

1. 选择**保存意图**。

------
#### [ Amazon Lex (Classic) ]

1. 在 Amazon Lex 控制台中，选择**意图**旁边的 **\$1** 图标，然后选择**创建新意图**。

1. 命名意图**SpeakToAgent**。

1. 选择 **SpeakToAgent**。

1. 添加示例言语，例如*与座席交谈*，然后选择 **\$1**。

1. 添加另一个言语，例如*二*，并选择 **\$1**。

1. 添加一条消息，让呼叫方知道其呼叫正在连接到座席。例如，“好的，座席将马上与您联系。”

1. 选择 **Save Intent (保存目的)**。

------

## 构建和测试 Amazon Lex 自动程序
<a name="lex-bot-build"></a>

在创建自动程序后，确保其可按预期正常工作。

------
#### [ Amazon Lex ]

1. 在页面底部，选择**构建**。这可能需要一两分钟。下图显示了**构建**按钮的位置。  
![\[“构建”按钮在页面上的位置。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lexv2-build-test-intent.png)

1. 构建完成后，选择**测试**。

1. 让我们测试一下**AccountLookup**意图：在 “**测试草稿版本” 窗格的** “**键入消息**” 框中，键入 **1**，然后按 Enter。然后键入一个虚构的账号并按下 Enter。下图显示了在哪里输入意图。  
![\[键入测试意图的框。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lexv2-test1.png)

   1. 清除测试框。

   1. 键入要测试的意图。

1. 要确认**SpeakToAgent**意图是否有效，请清除测试框，然后键入 **2** 并按 Enter。下图显示了清除测试然后输入 2 后测试的样子。  
![\[测试框。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lexv2-test2.png)

1. 关闭**测试草稿版本**面板。

------
#### [ Amazon Lex (Classic) ]

1. 选择**构建**。这可能需要一两分钟。

1. 在构建完成后，选择**测试聊天自动程序**，如下图中所示。  
![\[在页面右侧的“测试聊天自动程序”按钮。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lex-test-chatbot.png)

1. **让我们来测试一下**AccountLookup**意图：在 “**测试聊天机器人” 窗格的 “与你的机器人****聊天**” 框中，键入 1。**然后，键入虚构的账号。在下图中，箭头指向您要键入 1 的框。  
![\[测试自动程序，用于键入消息的框。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lex-test-run.png)

1. 选择**清除聊天历史记录**。

1. 要确认**SpeakToAgent**意图是否有效，请键入 **2**。

------

## 创建自动程序版本（可选）
<a name="lex-bot-create-bot-version"></a>

在此步骤中，您将创建一个新的自动程序版本以在别名中使用。这就是创建可在生产环境中使用的别名的方式。测试别名受较低的节流限制。尽管这是一个测试演练，但创建版本仍是最佳实践。

------
#### [ Amazon Lex ]

1. 如果您在**意图**页面，选择**返回意图列表**。

1. 在左侧菜单上，选择**自动程序版本**。

1. 选择**创建版本**。

1. 查看**AccountBalance**机器人的详细信息，然后选择 “**创建**”。

   这会创建您的自动程序版本（版本 1）。您可以在非测试别名上切换版本，不必跟踪要发布的版本。  
![\[列出了版本 1 的“版本”页面。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lexv2-version1.png)

------

## 为自动程序创建别名
<a name="lex-bot-create-alias"></a>

------
#### [ Amazon Lex ]

1. 在左侧菜单中，选择**别名**。

1. 在**别名**页面，选择**创建别名**。

1. 在**别名**框中，输入一个名称，例如**测试**。在本演练的稍后部分，您将使用此别名在流中指定此自动程序的版本。
**重要**  
在生产环境中，请务必使用与 Amazon Lex 不同的别名，**TestBotAlias**对于 Amazon Lex classic，请务必使用**与 \$1** LATEST 不同的别名。 **TestBotAlias**而且 **\$1LATES** T 支持对 Amazon Lex 机器人进行有限数量的并发调用。有关更多信息，请参阅[运行时系统份额](https://docs.aws.amazon.com/lexv2/latest/dg/quotas.html#quotas-service)。

1. 对于**关联版本**，请选择您刚刚创建的版本，例如**版本 1**。

1. 选择**创建**。

------
#### [ Amazon Lex (Classic) ]

1. 选择**发布**。

1. 为自动程序提供别名。使用别名在流中指定此自动程序的版本，例如，**测试**。
**重要**  
在生产环境中，请务必使用与 Amazon Lex 不同的别名，**TestBotAlias**对于 Amazon Lex classic，请务必使用**与 \$1** LATEST 不同的别名。 **TestBotAlias**而且 **\$1LATES** T 支持对 Amazon Lex 机器人进行有限数量的并发调用。有关更多信息，请参阅[运行时系统服务限额](https://docs.aws.amazon.com/lex/latest/dg/gl-limits.html#gl-limits-runtime)。

1. 选择**发布**。

------

## 将 Amazon Lex 自动程序添加到您的 Amazon Connect 实例
<a name="lex-bot-add-to-connect"></a>

------
#### [ Amazon Lex ]

1. 打开 [Amazon Connect 控制台](https://console.aws.amazon.com/connect/)。

1. 选择要与 Amazon Lex 自动程序集成的 Amazon Connect 实例。  
![\[“Amazon Connect 虚拟联系中心实例”页面，实例别名。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/instance.png)

1. 在导航菜单上，选择**流**。

1. 在 **Amazon Lex** 下，使用下拉列表选择你的 Amazon Lex 机器人的区域，然后选择你的 Amazon Lex 机器人**AccountBalance**。

1. 从下拉列表中选择 Amazon Lex 自动程序别名（**测试**），然后选择 **\$1 添加 Lex 自动程序**。下图显示了配置后的 Amazon Lex 部分。  
![\[流页面的 Amazon Lex 部分。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lexv2-region-bot.png)

**注意**  
Amazon Connect 使用 Amazon Lex 基于资源的策略来调用您的 Amazon Lex 自动程序。当您将一个 Amazon Lex 自动程序与 Amazon Connect 实例关联时，该自动程序上基于资源的策略会更新，以授予 Amazon Connect 调用该自动程序的权限。有关 Amazon Lex 基于资源的策略的更多信息，请参阅 [Amazon Lex 如何与 IAM 配合使用](https://docs.aws.amazon.com/lexv2/latest/dg/security_iam_service-with-iam.html#security_iam_service-with-iam-resource-based-policies)。

------
#### [ Amazon Lex (Classic) ]

1. 打开 [Amazon Connect 控制台](https://console.aws.amazon.com/connect/)。

1. 选择要与 Amazon Lex 自动程序集成的 Amazon Connect 实例。

1. 在导航菜单上，选择**联系流**

1. 在 **Amazon Lex** 下，从下拉列表中选择 Amazon Lex Classic 自动程序的区域，然后选择您的 Amazon Lex Classic 自动程序。它的名字将带有后缀“(Classic)”。然后选择**添加 Lex 自动程序**。

------

## 创建流并添加您的 Amazon Lex 自动程序
<a name="lex-bot-create-flow-add-bot"></a>

**重要**  
如果您使用的是 Amazon Lex V2 自动程序，则您在 Amazon Connect 中的语言属性必须与构建 Lex 自动程序时使用的语言模型相匹配。这与 Amazon Lex (Classic) 不同。使用[设置语音](set-voice.md#set-voice-lexv2bot)数据块指示 Amazon Connect 语言模型，或者使用[设置联系属性](set-contact-attributes.md)数据块。

接下来，创建使用 Amazon Lex 自动程序的新流。当您创建流时，您需要配置播放给呼叫方的信息。

1. 使用对联系流和 Amazon Lex 自动程序具有权限的账户登录到您的 Amazon Connect 实例。

1. 在导航菜单上，选择**路由、流、创建流**，然后键入流的名称。

1. 在**交互**下，将[获取客户输入](get-customer-input.md)块拖到设计器中，然后将它连接到**入口点块**。

1. 选择**获取客户输入**数据块打开它。选择**文字转语音或聊天文本、输入文本**。

1. 键入一条消息向呼叫方提供有关他们可以执行什么操作的信息。例如，使用与机器人中使用的意图相匹配的消息，譬如“查询账户余额，请按 1 或说 1。联系座席，请按 2 或说 2。” 此消息在下图**获取客户输入**数据块的“属性”页面上显示。  
![\[“获取客户输入”数据块的“属性”页面。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lex-get-customer-input.png)

1. 选择 **Amazon Lex** 选项卡，如下图中所示。  
![\[“获取客户输入”数据块的“属性”页面上的 Amazon Lex 选项卡。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lexv2-get-customer-input2.png)

1. 在 “**名称**” 下拉列表中，选择您之前创建的**AccountBalance**机器人。

   1. 如果您选择了 Amazon Lex 自动程序，请在**别名**下使用下拉菜单选择自动程序别名，即**测试**。

   1. Amazon Lex Classic 自动程序的名字后面有后缀“(Classic)”。如果您选择了 Classic 自动程序，请在**别名**字段中输入要使用的别名。

   1. 对于 Amazon Lex V2 自动程序，您还可以选择手动设置自动程序别名 ARN。选择**手动设置**，然后键入要使用的自动程序别名的 ARN，或者使用动态属性设置 ARN。

1. 在**意图**下，选择**添加意图**。

1. 键入**AccountLookup**并选择 “**添加其他意图**”。下图显示了使用此信息配置的**意图**部分。  
![\[Amazon Lex 选项卡的“意图”部分。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lex-get-customer-input3.png)

1. 键入**SpeakToAgent**并选择 “**保存**”。

### 完成流
<a name="lex-bot-finish-flow"></a>

在此步骤中，您将完成向流中添加呼叫方与自动程序交互后运行的部分：

1. 如果呼叫方按 1 来获得他们的账户余额，使用**提示**数据块来播放信息并断开呼叫连接。

1. 如果呼叫方按 2 来与座席说话，请使用**设置队列**数据块以设置队列并将呼叫方转接到队列，这会终止流。

以下是创建流的步骤：

1. 在 In **ter** act 下，将 **Play 提示块**拖到设计器上，然后将 “**获取客户输入**” 块的**AccountLookup**节点连接到设计器。客户从 Amazon Lex 自动程序获取账户余额后，会播放**播放提示**数据块中的消息。

1. 在**结束/转接**下，将**断开链接**数据块拖入设计器，并与**播放提示**数据块连接。播放该提示信息后，呼叫会断开连接。

要完成**SpeakToAgent**意图，请执行以下操作：

1. 添加 **Set 工作队列**块并将其连接到 Ge **t 客户输入**块的**SpeakToAgent**节点。

1. 添加**转接到队列**数据块。

1. 将**设置客户队列流**数据块的成功节点连接到**转接队列**。

1. 选择**保存**，然后选择**发布**。

已结束的流类似于以下图像。流从**获取客户输入**数据块开始。该数据块会分支到**播放提示**或**设置客户队列**。

![\[流设计器中已完成的流。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/lex-contactflow-designer.png)


**提示**  
如果您的企业在单个自动程序中使用多个区域设置，请在流的开头添加一个[设置联系属性](set-contact-attributes.md)数据块。将此区块配置为使用 [\$1。 LanguageCode](connect-attrib-list.md#attribs-system-table)系统属性。

## 将流分配给电话号码
<a name="lex-bot-assign-number"></a>

当客户呼叫联络中心时，他们被送到的流是分配给他们呼叫的电话的流。要激活新的流，请将其分配给实例的一个电话号码。

1. 打开 Amazon Connect 控制台。

1. 选择**路由、电话号码**。

1. 在**管理电话号码**页面，选择要分配给流的电话号码。

1. 添加描述。

1. 在**流/IVR** 菜单中，选择您刚刚创建的流。

1. 选择**保存**。

## 试试看！
<a name="lex-bot-try-it"></a>

要测试自动程序和流，请呼叫您分配给流的号码。按照提示操作。

# 使用聊天频道和 Amazon Lex 的最佳实践
<a name="bp-lex-bot-chat"></a>

以下是一些将聊天频道和 Amazon Lex 结合使用的最佳实践。
+ 您可以对语音和聊天通道使用同一自动程序。但是，您可能希望自动程序根据渠道做出不同的响应。例如，您希望为语音返回 SSML，以便将数字作为电话号码读取，但您希望向聊天返回正常文本。您可以通过传递**渠道**属性来实现此目的。有关说明，请参阅[如何对语音和聊天使用同一 Amazon Lex 自动程序](one-bot-voice-chat.md)。
+ 对于语音，某些单词最好按照发音拼写以获得正确的发音，例如姓氏。如果您的场景是这种情况，请将其包含在自动程序的设计中。或者，您可以保持语音和聊天自动程序分开。
+ 告诉座席有关机器人的信息。当联系人连接到座席时，座席将在其窗口中看到整个转录。脚本包括来自客户和自动程序的文本。

# 在聊天中为客户添加 Amazon Lex 互动消息
<a name="interactive-messages"></a>

交互式消息包含丰富的消息，提供提示和预置的显示选项，供客户选择。这些消息由 Amazon Lex 提供支持，并使用 AWS Lambda 函数通过 Amazon Lex 进行配置。

**提示**  
如果您已与 Apple Messages for Business 集成，请参阅 Apple 网站上的[交互式消息类型](https://register.apple.com/resources/messages/msp-rest-api/type-interactive)。

## 验证限制
<a name="validation-limits"></a>

字符串字段限制（例如标题、副标题等）应由客户端（即自定义构建的界面或托管通信小部件）强制执行。[SendMessage](https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_SendMessage.html)API 仅检查字符串的总大小是否小于 20KB。
+ 当您使用托管通信小部件而不对其进行自定义时，如果字符串超出字段限制，则会在用户界面上将其截断并附加省略号（...）。您可以通过自定义小组件来确定如何强制执行字段限制。
+ 如果您要与其他平台（例如 Apple Messages for Business）集成，请查看本主题中针对 Amazon Connect 的限制，并查看文档中针对其他平台的限制。例如，旧版本的 iOS 不支持快速响应。

要成功发送消息，必须遵守所有其他字段限制。

## 消息显示模板
<a name="message-display-templates"></a>

Amazon Connect 提供以下消息显示模板。使用它们向聊天中的客户呈现信息：
+  [列表选择器](#list-picker)
+ [时间选取器](#time-picker)
+ [面板](#panel)
+ [快速回复](#quick-reply-template)
+ [轮播](#carousel-template)
+ [Apple 表单模板](#apple-form-template)
+ [Apple Pay 模板](#apple-pay-template)
+ [iMessage 应用程序模板](#imessage-app-template)
+ [WhatsApp list](#whatsapp-list)
+ [WhatsApp 回复按钮](#whatsapp-reply-button)
+ [丰富的标题和字幕格式](#rich-link-formatting)

这些模板定义了信息的呈现方式，以及聊天界面中会显示哪些信息。通过聊天发送交互式消息时，流会验证消息格式是否遵循其中一个模板。

## 列表选择器模板
<a name="list-picker"></a>

使用列表选择器模板向客户显示最多六个选项的列表。每个选项都可以有自己的图像。

下图显示了列表选择器模板如何在聊天中呈现信息的两个示例。
+ 其中一张图像显示了三个按钮，每个按钮都用文字表示一种水果的名字：苹果、橙子、香蕉。
+ 第二张图像显示了一家商店的图片，在商店下方有三个按钮，每个按钮都有水果的名称、图片和价格。

![\[列表选择器模板在聊天中呈现信息。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/interactive-messages-listpicker-images2.png)


以下代码是您可以在 Lambda 中使用的列表选择器模板。注意以下几点：
+ **粗体文本**表示必填参数。
+ 在某些情况下，如果父元素不是必填项，但父元素中的字段是必填字段，则这些字段就是必填字段。例如，请参阅以下模板中的 `data.replyMessage` 结构。如果该结构存在，则 `title` 为必填项。否则完整的 `replyMessage` 为可选项。

```
{
   "templateType":"ListPicker",                       
   "version":"1.0",                                   
   "data":{                                           
      "replyMessage":{                             
         "title":"Thanks for selecting!",             
         "subtitle":"Produce selected",
         "imageType":"URL",                                
         "imageData":"https://interactive-msg.s3-us-west-2.amazonaws.com/fruit_34.3kb.jpg",                          
         "imageDescription":"Select a produce to buy"
      },
      "content":{                                       
         "title":"What produce would you like to buy?",
         "subtitle":"Tap to select option",
         "imageType":"URL",                       
         "imageData":"https://interactive-msg.s3-us-west-2.amazonaws.com/fruit_34.3kb.jpg",                  
         "imageDescription":"Select a produce to buy",
         "elements":[                                   
            {
               "title":"Apple",                          
               "subtitle":"$1.00",
               "imageType":"URL",
               "imageData":"https://interactive-message-testing.s3-us-west-2.amazonaws.com/apple_4.2kb.jpg"
            },
            {
               "title":"Orange",                         
               "subtitle":"$1.50",
               "imageType":"URL",                  
               "imageData":"https://interactive-message-testing.s3-us-west-2.amazonaws.com/orange_17.7kb.jpg",           
            },
             {
               "title":"Banana",                         
               "subtitle":"$10.00",
               "imageType":"URL",                  
               "imageData":"https://interactive-message-testing.s3-us-west-2.amazonaws.com/banana_7.9kb.jpg",            
               "imageDescription":"Banana"
            }
         ]
      }
```

### 列表选择器限制
<a name="list-picker-limits"></a>

如果您选择从头开始构建自己的 Lambda，下表列出了每个列表选择器元素的限制。必填参数以粗体显示。

要发送不受限制的选项，请在应用程序中实施操作按钮。有关更多信息，请参阅[在交互式消息列表选择器/面板中实施操作按钮。](https://github.com/amazon-connect/amazon-connect-chat-interface/blob/master/.github/docs/InteractiveMessageActionButtonImplementation.md)


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/interactive-messages.html)

**注意**  
如果您正在使用 `targetForLinks` 字段和 Amazon Connect 通信小部件，为了在同一浏览器选项卡中打开链接，您必须在小部件代码片段中添加以下属性，以允许当前 iframe 在同一选项卡中打开并导航链接：  

```
amazon_connect('updateSandboxAttributes', 'allow-scripts allow-same-origin allow-popups allow-downloads allow-top-navigation-by-user-activation')                                       
```

## 时间选取器模板
<a name="time-picker"></a>

时间选取器模板非常有用，能让客户安排预约。您最多可以在聊天中向客户提供 40 个时段。

下图显示了时间选取器模板如何在聊天中呈现信息的两个示例。
+ 其中一张图像显示了一个日期，在其下方显示了一个时段。
+ 第二张图像显示了一个日期，在其下方显示了两个时段。

![\[时间选取器模板在聊天中呈现信息。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/interactive-messages-timepicker.png)


下图显示了带有图像的时间选择器

**注意**  
如果您在 [Apple Messages for Business](apple-messages-for-business.md) 频道中使用此消息模板，但没有添加图片，Amazon Connect 将在回复和响应消息中添加默认图片。

![\[带有图像的时间选择器。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/interactive-messages-timepicker-with-image.png)


以下代码是您可以在 Lambda 中使用的时间选取器模板。注意以下几点：
+ **粗体文本**表示必填参数。
+ 在某些情况下，如果父元素不是必填项，但父元素中的字段是必填字段，则这些字段就是必填字段。例如，请参阅以下模板中的 `data.replyMessage` 结构。如果该结构存在，则 `title` 为必填项。否则完整的 `replyMessage` 为可选项。

```
{
   "templateType":"TimePicker",                                 
   "version":"1.0",                                             
   "data":{                                                    
      "replyMessage":{
         "title":"Thanks for selecting",                        
         "subtitle":"Appointment selected",
         "imageType":"URL",                                       
         "imageData":"https://interactive-msg.s3-us-west-2.amazonaws.com/booked.jpg",
         "imageDescription":"Appointment booked"
      },
      "content":{                                               
         "title":"Schedule appointment",                       
         "subtitle":"Tap to select option",
         "imageType":"URL",                                       
         "imageData":"https://interactive-msg.s3-us-west-2.amazonaws.com/calendar.jpg",
         "imageDescription":"Appointment booked",
         "timeZoneOffset":-450,
         "location":{
            "latitude":47.616299,                               
            "longitude":-122.4311,                              
            "title":"Oscar",                                    
            "radius":1,
         },
         "timeslots":[                                          
               {
                  "date" : "2020-10-31T17:00+00:00",             
                  "duration": 60,                               
               },
               {
                  "date" : "2020-11-15T13:00+00:00",            
                  "duration": 60,                              
               },
               {
                  "date" : "2020-11-15T16:00+00:00",            
                  "duration": 60,                              
               }
            ],           
         }
      }
   }
}
```

### 时间选取器限制
<a name="time-picker-limits"></a>

下表列出了每个时间选取器元素的限制。如果您选择从头开始构建自己的 Lambda，请使用此信息。必填参数以粗体显示。


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/interactive-messages.html)

## 面板模板
<a name="panel"></a>

通过使用面板模板，您可以在一个问题下向客户提供最多 10 个选项。但是，只能包含一张图像，而不是每个选项一张。

下图显示了面板模板如何在聊天中呈现信息的示例。它在消息的顶部显示了一张图像，在图像下方显示了一个提示，询问*我该怎么帮您？ 点击选择选项*。在提示下向客户显示了三个选项：**检查自助服务选项**、**与座席交谈**、**结束聊天**。

![\[面板模板在聊天中呈现信息。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/interactive-messages-panel1.png)


以下代码是您可以在 Lambda 中使用的面板模板。注意以下几点：
+ **粗体文本**表示必填参数。
+ 在某些情况下，如果父元素不是必填项，但父元素中的字段是必填字段，则这些字段就是必填字段。例如，请参阅以下模板中的 `data.replyMessage` 结构。如果该结构存在，则 `title` 为必填项。否则完整的 `replyMessage` 为可选项。

```
{
   "templateType":"Panel",                            
   "version":"1.0",                                   
   "data":{                                          
      "replyMessage":{                             
         "title":"Thanks for selecting!",             
         "subtitle":"Option selected",
      },
      "content":{                                      
         "title":"How can I help you?",                
         "subtitle":"Tap to select option",
         "imageType":"URL",                       
         "imageData":"https://interactive-msg.s3-us-west-2.amazonaws.com/company.jpg",                  
         "imageDescription":"Select an option",
         "elements":[                                 
            {
               "title":"Check self-service options",   
            },
            {
               "title":"Talk to an agent",                     
            },
            {
               "title":"End chat",                    
            }
         ]
      }
   }
}
```

### 面板限制
<a name="panel-limits"></a>

如果您选择从头开始构建自己的 Lambda，下表列出了每个面板元素的限制。必填参数以粗体显示。

要发送不受限制的选项，请在应用程序中实施操作按钮。有关更多信息，请参阅[在交互式消息列表选择器/面板中实施操作按钮。](https://github.com/amazon-connect/amazon-connect-chat-interface/blob/master/.github/docs/InteractiveMessageActionButtonImplementation.md)


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/interactive-messages.html)

## 快速回复模板
<a name="quick-reply-template"></a>

使用快速回复消息获得客户的简单回复，以及他们在内联列表中对客户的回复。不支持使用图像进行快速响应。

下图显示了快速回复模板如何在聊天中呈现信息的示例。

![\[面板模板在聊天中呈现信息。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/quick-reply-template.png)


以下代码是您可以在 Lambda 中使用的快速回复模板。

```
{
    "templateType": "QuickReply",
    "version": "1.0",
    "data": {
        "replyMessage": {
            "title": "Thanks for selecting!"
        },
        "content": {
            "title": "Which department would you like?",
            "elements": [{
                    "title": "Billing"
                },
                {
                    "title": "Cancellation"
                },
                {
                    "title": "New Service"
                }
            ]
        }
    }
}
```

### 快速回复限制
<a name="quickreply-limits"></a>

下表列出了每个快速回复元素的限制。如果您选择从头开始构建自己的 Lambda，请使用此信息。必填参数以粗体显示。


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/interactive-messages.html)

## 轮播模板
<a name="carousel-template"></a>

使用轮播在一条消息中向客户显示最多 5 个列表选择器或面板。与列表选择器和时间选取器类似，您可以使用 SHOW\$1MORE 功能向轮播添加更多选项。

以下 GIF 显示了轮播模板如何在聊天中呈现信息的示例。客户使用左右箭头滚动浏览图像轮播。

![\[客户聊天体验中的轮播。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/carousel-interactive.gif)


下图显示了两个**了解更多**超链接，它们是轮播选择器超链接元素的示例。

![\[带有超链接的轮播选择器。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/carousel-interactive1.png)


以下代码是您可以在 Lambda 中使用的轮播模板。

```
{
  "templateType": "Carousel",            
  "version": "1.0",                      
  "data": {                              
      "content": {                           
        "title": "View our popular destinations",   
        "elements": [                               
        {
          "templateIdentifier": "template0",        
          "templateType": "Panel",
          "version": "1.0",
          "data": {
            "content": {
              "title": "California",
              "subtitle": "Tap to select option",
              "elements": [
                {
                  "title": "Book flights"
                },
                {
                  "title": "Book hotels"
                },
                {
                  "title": "Talk to agent"
                }
              ]
            }
          }
        },
        {
          "templateIdentifier": "template1",   
          "templateType": "Panel",
          "version": "1.0",
          "data": {
            "content": {
              "title": "New York",
              "subtitle": "Tap to select option",
              "elements": [
                {
                  "title": "Book flights"
                },
                {
                  "title": "Book hotels"
                },
                {
                  "title": "Talk to agent"
                }
              ]
            }
          }
        }
      ]
    }
  }
}
```

对于托管通信小部件用户：
+ 在轮播模板上的选择会生成结构如以下示例的 JSON 字符串响应，然后发送回 Lambda（其他交互式消息类型只会返回带有 `selectionText` 值的常规字符串响应）：

  ```
  {
      templateIdentifier: "template0",
      listTitle: "California",
      selectionText: "Book hotels"
  }
  ```
+ 在轮播中，你可以在列表元素中提供超链接。 picker/panel 要创建超链接而不是按钮，请为本应是超链接的元素添加以下其他字段：

  ```
  {
      title: "Book flights",
      ...
      type: "hyperlink",
      url: "https://www.example.com/Flights"
  }
  ```

### 轮播限制
<a name="carousel-limits"></a>

下表列出了每个轮播元素的限制。如果您选择从头开始构建自己的 Lambda，请使用此信息。必填参数以粗体显示。


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/interactive-messages.html)

## Apple 表单模板
<a name="apple-form-template"></a>

**注意**  
 此模板仅适用于 Apple Messages for Business 联系流。

企业可以通过一条消息向终端客户发送表单交互式消息，其中包含多页要求输入的内容。当终端客户的 Apple 设备收到消息后，他们可以打开表单并浏览页面，为每个页面回复，然后在表单末尾提交所有回复。

例如，企业可以将 Apple 表单用于各种用途，包括分类流、客户调查和账户创建/注册。

**警告**  
互动消息内容和终端客户回复都存储在联系记录副本中，其他聊天参与者和联系人分析师可以访问文字记录查看。为防止 PII 在联系**结束后出现在您的联系人**记录笔[录中，您需要在 step-by-step指南流程中使用 “设置记录和分析行为” 块](set-recording-behavior.md)Contact Lens，[启用](sensitive-data-redaction.md)和启用敏感日期的编辑。有关如何启用 PII 编辑的完整详细信息，请参阅[启用敏感数据编辑](enable-analytics.md#enable-redaction)。

 受支持的页面类型是：
+ **ListPicker**：用户必须从支持图像的选项中进行选择的列表。
+ **WheelPicker**: 与之类似， ListPicker 但选择是通过可滚动的选项轮进行的。
+ **DatePicker**: 日历视图，用户可以在其中选择日期。
+ **输入**：用户必须填写的文本字段。

以下代码是您可以在 Lambda 中使用的 Apple 表单模板的示例。

**注意**  
 **粗体文本**是必填参数。
 在某些情况下，如果请求中存在父元素，并且不是必填/粗体，但其中的字段是必填/粗体，则这些字段就是必填字段。

 简单调查表单示例：

```
{
  "templateType": "AppleForm",
  "version": "1.0",
  "data": {
    "content": {
      "title": "Survey",
      "pages": [
        {
          "pageType": "DatePicker",
          "title": "Date you visited",
          "subtitle": "When did you last visit?",
          "minDate": "2024-01-02"
        },
        {
          "pageType": "ListPicker",
          "title": "Rating",
          "subtitle": "How do you rate the experience?",
          "items": [
            {
              "title": "Good",
              "imageType": "URL",
              "imageData": "https://mybucket.s3.us-west-2.amazonaws.com/good.jpg"
            },
            {
              "title": "Okay",
              "imageType": "URL",
              "imageData": "https://mybucket.s3.us-west-2.amazonaws.com/okay.jpg"
            },
            {
              "title": "Poor",
              "imageType": "URL",
              "imageData": "https://mybucket.s3.us-west-2.amazonaws.com/poor.jpg"
            }
          ]
        },
        {
          "pageType": "ListPicker",
          "title": "Dine type",
          "subtitle": "Select all dine types that apply",
          "multiSelect": true,
          "items": [
            {
              "title": "Pickup"
            },
            {
              "title": "Dine-in"
            },
            {
              "title": "Delivery"
            }
          ]
        },
        {
          "pageType": "WheelPicker",
          "title": "Visits",
          "subtitle": "How often do you visit?",
          "items": [
            {
              "title": "Often"
            }
            {
              "title": "Sometimes"
            },
            {
              "title": "Rarely"
            }
          ]
        },
        {
          "pageType": "Input",
          "title": "Additional notes",
          "subtitle": "Anything else you'd like to mention about your visit?",
          "multiLine": true
        }
      ]
    }
  }
}
```

### Apple 表单限制
<a name="apple-forms-limits"></a>

#### InteractiveMessage
<a name="apple-forms-limits-interactivemessage"></a>


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| 版本 | 字符串  | 是  | 版本号。允许的值：“1.0”  | 
| templateType  | TemplateType  | 是  | 互动消息模板类型。允许的值：[” ListPicker “、” “、TimePicker “面板”、“”、“”、QuickReply “Carousel”、ViewResource “”、“” AppleForm“]  | 
| 数据 | InteractiveMessageData  | 是  | 互动消息数据  | 

#### InteractiveMessageData
<a name="apple-forms-limits-interactivemessagedata"></a>


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| content | InteractiveMessageContent  | 是  | 主要互动消息内容  | 
| replyMessage  | ReplyMessage  | 否  | 发送互动消息回复后的消息显示配置  | 

#### AppleFormContent
<a name="apple-forms-limits-appleformcontent"></a>


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| 标题 | 字符串  | 是  | 表单顶部标题。显示在 Apple 接收消息气泡和文字记录渲染中  | 
| subtitle  | 字符串  | 否  | 在中用作字幕 ReceivedMessage  | 
| imageType  | 字符串  | 否  | 有效值：“URL” 用于中的图片 ReceivedMessage  | 
| imageData  | 字符串  | 否  | S3 图片网址用于中的图片 ReceivedMessage  | 
| pages  | AppleFormPage[]  | 是  | 表单页面列表  | 
| showSummary  | 布尔值  | 否  | 是否在提交前显示要查看的回复的摘要页面默认：False（无 confirmation/summary 页面）  | 
| splashPage  | AppleFormSplashPage  | 否  | 在实际页面之前显示的初始醒目页面 默认：无醒目页面  | 

#### AppleFormSplashPage
<a name="apple-forms-limits-appleformsplashpage"></a>


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| 标题 | 字符串  | 是  | 醒目页面的标题  | 
| subtitle  | 字符串  | 否  | 副标题/醒目页面正文  | 
| imageType  | ImageType  | 否  | 在醒目页面中显示图像时显示允许的值：“URL” 默认：不显示图像  | 
| imageData  | 字符串  | 否  | 对于 imageType= “URL”，这是 URL 值 默认：不显示图像  | 
| buttonTitle  | 字符串  | 是  | “继续”按钮文本。Apple 要求，不支持具有本地化功能的默认文本  | 

#### AppleFormPage
<a name="apple-forms-limits-appleformpage"></a>
+  表单页面基本模型。从此模型延伸出的特定页面类型 


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| pageType  | ApplePageType  | 是  | 页面类型枚举。允许的值：[“输入”、DatePicker “”、WheelPicker “”、ListPicker “]  | 
| 标题 | 字符串  | 是  | 页面标题  | 
| subtitle  | 字符串  | 是  | 页面副标题。用于确认页面  | 

#### AppleFormDatePickerPage
<a name="apple-forms-limits-appleformdatapickerpage"></a>

 **AppleFormDatePickerPage**扩展 [AppleFormPage](#apple-forms-limits-appleformpage) 


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| pageType  | ApplePageType  | 是  | 值：“DatePicker”  | 
| labelText  | 字符串  | 否  | 日期输入旁边显示的文本。参见附录中的示例屏幕截图  | 
| helperText  | 字符串  | 否  | 日期输入下方显示帮助文本。参见附录“默认：无辅助文本”中的屏幕截图  | 
| dateFormat  | 字符串  | 否  | ISO 8601 日期格式。默认值：MM/dd/yyyy | 
| startDate  | 字符串  | 否  | 采用有效日期格式的初始/默认选定日期 默认：发送消息时最终用户的当前日期  | 
| minDate  | 字符串  | 否  | 允许以有效的日期格式选择的最小日期 默认：无最小日期  | 
| maxDate  | 字符串  | 否  | 允许以有效日期格式选择的最大日期 默认：发送消息时最终用户的当前日期  | 

#### AppleFormListPickerPage
<a name="apple-forms-limits-appleformlistpickerpage"></a>

 **AppleFormListPickerPage**扩展 [AppleFormPage](#apple-forms-limits-appleformpage) 


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| pageType  | ApplePageType  | 是  | 值：“ListPicker”  | 
| multiSelect  | 布尔值  | 否  | 允许选择多个项目 默认值：false（单选）  | 
| 物品 | AppleFormListPickerPageItem[]  | 是  | 列表页项目列表  | 

#### AppleFormListPickerPageItem
<a name="apple-forms-limits-appleformlistpickerpageitem"></a>

 **AppleFormListPickerPageItem**扩展 [AppleFormPage](#apple-forms-limits-appleformpage) 


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| 标题 | 字符串  | 是  | 显示项目文本  | 
| imageType  | ImageType  | 否  | 在项目中显示图像时显示允许的值：“URL” 默认：不显示图像  | 
| imageData  | 字符串  | 否  | 对于 imageType= “URL”，这是 URL 值 默认：不显示图像  | 

**注意**  
图像模型与现有的交互式消息模型 (ListPicker) 类似，但`imageDescription`不包括在内，它用于聊天小部件/网络聊天中的图像替代文本，而在 Apple 交互式消息中则被忽略。

#### AppleFormWheelPickerPage
<a name="apple-forms-limits-appleformwheelpickerpage"></a>

 **AppleFormWheelPickerPage**扩展 [AppleFormPage](#apple-forms-limits-appleformpage) 


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| pageType  | ApplePageType  | 是  | 值：“WheelPicker”  | 
| 物品 | AppleFormWheelPickerPageItem[]  | 是  | 旋转选择器项目清单  | 
| labelText  | 字符串  | 否  | 输入旁边显示的文本。参见附录中的示例屏幕截图  | 

#### AppleFormWheelPickerPageItem
<a name="apple-forms-limits-appleformwheelpickerpageitem"></a>

 **AppleFormWheelPickerPageItem**扩展 [AppleFormPage](#apple-forms-limits-appleformpage) 


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| 标题 | 字符串  | 是  | 显示选取器项目的文本  | 

#### AppleFormInputPage
<a name="apple-forms-limits-appleforminputpage"></a>

 **AppleFormInputPage**扩展 [AppleFormPage](#apple-forms-limits-appleformpage) 


| 字段  | 类型  | 必需  | 说明/注释  | 
| --- | --- | --- | --- | 
| pageType  | ApplePageType  | 是  | 值：“Input”  | 
| labelText  | 字符串  | 否  | 输入方框旁边显示的文本。参见附录中的示例屏幕截图  | 
| helperText  | 字符串  | 否  | 在输入框下方显示其他文本，默认：无帮助程序文本  | 
| placeholderText  | 字符串  | 否  | 没有输入时初始显示的占位符文本 默认：“（可选）”或“（必填）”占位符文本  | 
| prefixText  | 字符串  | 否  | 要在输入旁边显示的前缀文本。例如：“\$1”，当输入为货币值时 默认：无前缀文本  | 
| 必需的 | 布尔值  | 否  | 是否要求最终用户提供输入 默认值：false  | 
| multiLine  | 布尔值  | 否  | 是否可以提供多行输入 默认值：false（单行）  | 
| maxCharCount  | 数字  | 否  | 输入的最大字符数。在 Apple 客户端上强制执行 默认：无限制  | 
| 正则表达式 | 字符串  | 否  | 用于对所提供的输入内容进行限制的 Regex 字符串 默认：无 regex 限制  | 
| keyboardType  | 字符串  | 否  | 确定最终用户输入允许值时显示的键盘类型：与 Apple 相同。参阅[文档](https://register.apple.com/resources/messages/msp-rest-api/type-interactive#form-message)。一些允许的值：numberPad、phonePad、emailAddress  | 
| textContentType  | 字符串  | 否  | 有助于在 Apple 设备上使用自动填充建议。  允许的值：与 Apple 相同。参阅[文档](https://register.apple.com/resources/messages/msp-rest-api/type-interactive#form-message)。一些允许的值：电话号码、、FamilyName fullStreetAddress  | 

## Apple Pay 模板
<a name="apple-pay-template"></a>

**注意**  
此模板仅适用于 Apple Messages for Business 联系流。

 使用 Apple 支付模板，为客户提供一种简单而安全的方式，让他们通过使用 Apple Pay 的 Apple Messages for Business 购买商品和服务。

 以下代码是您可以在 Lambda 中使用的 Apple Pay 模板。

**注意**  
 **粗体文本**是必填参数。
 在某些情况下，如果请求中存在父元素，并且不是必填/粗体，但其中的字段是必填/粗体，则这些字段就是必填字段。

```
{
  "templateType":"ApplePay",
  "version":"1.0",
  "data":{
    "content":{
      "title":"Halibut",
      "subtitle":"$63.99 at Sam's Fish",
      "imageType":"URL",
      "imageData":"https://interactive-msg.s3-us-west-2.amazonaws.com/fish.jpg",
      "payment": {
        "endpoints": {
          "orderTrackingUrl": "https://sams.example.com/orderTrackingUrl/",
          "paymentGatewayUrl": "https://sams.example.com/paymentGateway/",
          "paymentMethodUpdateUrl": "https://sams.example.com/paymentMethodUpdate/",
          "shippingContactUpdateUrl": "https://sams.example.com/shippingContactUpdate/",
          "shippingMethodUpdateUrl": "https://sams.example.com/shippingMethodUpdate/",
          "fallbackUrl": "https://sams.example.com/paymentGateway/"
        },
        "merchantSession": {
          "epochTimestamp": 1525730094057,
          "expiresAt": 1525730094057,
          "merchantSessionIdentifier": "PSH40080EF4D6.........9NOE9FD",
          "nonce": "fe72cd0f",
          "merchantIdentifier": "merchant.com.sams.fish",
          "displayName": "Sam's Fish",
          "signature": "308006092a8.......09F0W8EGH00",
          "initiative": "messaging",
          "initiativeContext": "https://sams.example.com/paymentGateway/",
          "signedFields": [
            "merchantIdentifier",
            "merchantSessionIdentifier",
            "initiative",
            "initiativeContext",
            "displayName",
            "nonce"
          ],
        },
        "paymentRequest": {
          "applePay": {
            "merchantCapabilities": [
              "supports3DS",
              "supportsDebit",
              "supportsCredit"
            ],
            "merchantIdentifier": "merchant.com.sams.fish",
            "supportedNetworks": [
              "amex",
              "visa",
              "discover",
              "masterCard"
            ]
          },
          "countryCode": "US",
          "currencyCode": "USD",
          "lineItems": [
            {
              "amount": "59.00",
              "label": "Halibut",
              "type": "final"
            },
            {
              "amount": "4.99",
              "label": "Shipping",
              "type": "final"
            }
          ],
          "requiredBillingContactFields": [
            "postalAddress"
          ],
          "requiredShippingContactFields": [
            "postalAddress",
            "phone",
            "email",
            "name"
          ],
          "shippingMethods": [
            {
              "amount": "0.00",
              "detail": "Available within an hour",
              "identifier": "in_store_pickup",
              "label": "In-Store Pickup"
            },
            {
              "amount": "4.99",
              "detail": "5-8 Business Days",
              "identifier": "flat_rate_shipping_id_2",
              "label": "UPS Ground"
            },
            {
              "amount": "29.99",
              "detail": "1-3 Business Days",
              "identifier": "flat_rate_shipping_id_1",
              "label": "FedEx Priority Mail"
            }
          ],
          "total": {
            "amount": "63.99",
            "label": "Sam's Fish",
            "type": "final"
          },
          "supportedCountries" : [
            "US",
            "CA",
            "UK",
            "JP",
            "CN"
          ]
        }
      },
      "requestIdentifier" : "6b2ca008-1388-4261-a9df-fe04cd1c23a9"
    }
  }
}
```

### Apple Pay 限制
<a name="apple-pay-limits"></a>


| 父字段  | 字段  | 必需  | 最少字符  | 最多字符  | 其他要求  | 
| --- | --- | --- | --- | --- | --- | 
|  | templateType  | 是  |  |  | 有效的模板类型  | 
|  | 数据 | 是  |  |  |  | 
|  | 版本 | 是  |  |  | 必须为“1.0" | 
| 数据 | content | 是  |  |  |  | 
| content | 标题 | 是  | 1  | 512  | 收到的消息气泡的标题  | 
|  | subtitle  | 否  | 0  | 512  | 在接收到的消息气泡标题下方显示的副标题  | 
|  | imageData  | 否  | 0  | 200  | 必须是可公开访问的有效 URL  | 
|  | imageType  | 否  | 0  | 50  | 必须是“URL”  | 
|  | 付款 | 是  |  |  | 一本包含提供 Apple Pay 请求具体信息的字段的字典。 | 
|  | requestIdentifier  | 否  |  |  | 字符串， ApplePay 请求的标识符。如果未指定，则将生成并使用 UUID。 | 
| 付款 | 端点 | 是  |  |  | 一本包含付款处理、联系人更新和订单跟踪端点的字典。 | 
|  | merchantSession  | 是  |  |  | 一本包含 Apple Pay 在请求新的付款会话后提供的付款会话的字典。 | 
|  | paymentRequest  | 是  |  |  | 一本包含付款请求信息的字典  | 
| 端点 | paymentGatewayUrl  | 是  |  |  | 字符串。由 Apple Pay 调用，通过支付提供商处理付款。此 URL 应与商家会话的 initiativeContext 字段中的 URL 匹配  | 
|  | fallbackUrl  | 否  |  |  | 一个可在网页浏览器中打开的 URL，以便客户在设备无法使用 Apple Pay 付款时完成购买。如果指定，则需要匹配 fallbackURL。 paymentGatewayUrl | 
|  | orderTrackingUrl  | 否  |  |  | 完成订单后，Messages for Business 会调用该功能，让您有机会在系统中更新订单消息。 | 
|  | paymentMethodUpdate网址 | 否  |  |  | 当客户更改付款方式时，Apple Pay 会调用该功能。如果您未实现此端点并在字典中包含此密钥，则客户会看到一条错误消息。 | 
|  | shippingContactUpdate网址 | 否  |  |  | 当客户更改收货地址信息时，Apple Pay 会调用该功能。如果您未实现此端点并在字典中包含此密钥，则客户会看到一条错误消息  | 
|  | shippingMethodUpdate网址 | 否  |  |  | 当客户更改配送方式时，Apple Pay 会调用该功能。如果您未实现此端点并在字典中包含此密钥，则客户会看到一条错误消息。 | 
| merchantSession  | displayName  | 是  | 1  | 64  | 字符串。适合显示的商店规范名称。不要将名称本地化。 | 
|  | initiative  | 是  |  |  | 字符串。必须是“消息传递”  | 
|  | initiativeContext  | 是  |  |  | 字符串。传递您的支付网关 URL。 | 
|  | merchantIdentifier  | 是  |  |  | 字符串。代表 Apple Pay 商家的唯一标识符。 | 
|  | merchantSessionIdentifier  | 是  |  |  | 字符串。代表 Apple Pay 商户会话的唯一标识符。 | 
|  | epochTimestamp  | 是  |  |  | 字符串。时间表示为自 1970 年 1 月 1 日（星期四）00:00:00 UTC 起已过去的秒数。 | 
|  | expiresAt  | 是  |  |  | 字符串。到期时间表示为自 1970 年 1 月 1 日（星期四）00:00:00 UTC 起已过去的秒数。 | 
|  | nonce  | 否  |  |  | 二进制。检查互动完整性的一次性字符串。 | 
|  | signature  | 否  |  |  | 二进制。对互动进行签名的公钥的哈希值。 | 
|  | signedFields  | 否  |  |  | 包含签名属性的字符串列表。 | 
| paymentRequest  | applePay  | 是  |  |  | 一本描述 Apple Pay 配置的字典。 | 
|  | countryCode  | 是  |  |  | 字符串。商家的双字母 ISO 3166 国家/地区代码。 | 
|  | currencyCode  | 是  |  |  | 字符串。付款的三字母 ISO 4217 货币代码。 | 
|  | lineItems  | 否  |  |  | 一系列解释付款和额外费用的细列项目。订单项不是必填项。但是，如果存在 lineItems 密钥，则数组不能为空。 | 
|  | total  | 是  |  |  | 一本包含总数的字典。总金额必须大于零才能通过验证。 | 
|  | requiredBillingContact字段 | 否  |  |  | 客户处理交易所需的账单信息清单。有关可能的字符串的列表，请参阅[requiredBillingContact字段](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest/2216120-requiredbillingcontactfields)。只要求填写处理付款所需的联系人信息。要求提供不必要的字段会增加交易的复杂性，从而增加客户取消付款请求的几率。 | 
|  | requiredShippingContact字段 | 否  |  |  | 为配送订单而要求客户提供的配送或联系信息清单。例如，如果您需要客户的电子邮件或电话号码，请提供此密钥。有关可能的字符串的列表，请参阅[requiredShippingContact字段](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest/2216121-requiredshippingcontactfields)。 | 
|  | shippingMethods  | 否  |  |  | 一个列出了可用配送方式的数组。Apple Pay 付款页面会将数组中的第一种配送方式显示为默认配送方式。 | 
|  | supportedCountries  | 否  |  |  | 一个支持的国家的数组。列出每个国家/地区的 ISO 3166 国家/地区代码。 | 
| applePay  | merchantIdentifier  | 是  |  |  | 代表 Apple Pay 商家的唯一标识符。 | 
|  | merchantCapabilities  | 是  |  |  | 一个商家支持的付款功能的数组。该数组必须包含 supports3DS，也可以选择包含 supportsCredit、supportsDebit 和 supportsEMV。 | 
|  | supportedNetworks  | 是  |  |  | 一个商家支持的付款网络的数组。该数组必须包含以下一个或多个值：amex、discover、jcb、masterCard、privateLabel 或 visa  | 
| lineItem  | amount  | 是  |  |  | 行项目的货币金额。 | 
|  | label  | 是  |  |  | 行项目的简短本地化描述。 | 
|  | 键入 | 否  |  |  | 一个表示行项目是最终项目还是待定项目的值。 | 
| total  | amount  | 是  |  |  | 付款的总金额。 | 
|  | label  | 是  |  |  | 付款的简短本地化描述。 | 
|  | 键入 | 否  |  |  | 一个表示付款是最终项目还是待定项目的值。 | 
| shippingMethods  | amount  | 是  |  |  | 字符串。与此配送方式相关的非负成本。 | 
|  | detail  | 是  |  |  | 字符串。配送方式的补充描述。 | 
|  | label  | 是  |  |  | 字符串。配送方式的简短描述。 | 
|  | identifier  | 是  |  |  | 字符串。客户定义的值，用于标识此配送方式。 | 

## iMessage 应用程序模板
<a name="imessage-app-template"></a>

**注意**  
此模板仅适用于 Apple Messages for Business 联系流。

 使用 iMessage 应用程序模板向客户展示您定制的 iMessage 应用程序。

 以下代码是您可以在 Lambda 函数中使用的 iMessage 应用程序模板示例。  

```
{
   templateType: AppleCustomInteractiveMessage,
   version: "1.0",
   data: {
       content: {
           appIconUrl: "https://interactive-message-testing.s3-us-west-2.amazonaws.com/apple_4.2kb.jpg",
           appId: "123456789",
           appName: "Package Delivery",
           title: "Bubble Title CIM",
           bid: "com.apple.messages.MSMessageExtensionBalloonPlugin:{team-id}:{ext-bundle-id}",
           dataUrl: "?deliveryDate=26-01-2024&destinationName=Home&street=1infiniteloop&state=CA&city=Cupertino&country=USA&postalCode=12345&latitude=37.331686&longitude=-122.030656&isMyLocation=false&isFinalDestination=true",
           subtitle: "Bubble package",
       },
       replyMessage: {
           title: "Custom reply message title",
           subtitle: "Custom reply message subtitle",
           imageType: "URL",
           imageData: "https://interactive-msg.s3-us-west-2.amazonaws.com/fruit_34.3kb.jpg",
       }
   }
}
```

### iMessage 应用程序限制
<a name="imessage-apps-limits"></a>


|  **父字段**  |  **字段**  |  **必填**  |  **Type**  |  **其他说明**  | 
| --- | --- | --- | --- | --- | 
|  |  templateType  | 是  | TemplateType  | 有效的模板类型，“AppleCustomInteractiveMessage”  | 
|  |  data  | 是  | InteractiveMessageData  | 包含内容和 receivedMessage 字典  | 
|  |  版本  | 是  | 字符串  | 必须为“1.0" | 
|  data  |  content  | 是  | InteractiveMessageContent  | iMessage 应用程序的互动内容  | 
|  |  replyMessage  | 是  | ReplyMessage  | 发送互动消息回复后的消息显示配置  | 
|  content  |  appIconUrl  | 是  | 字符串  | AWS S3 网址  | 
|  |  appId  | 是  | 字符串  | 商业 IMessage 应用程序 ID  | 
|  |  appName  | 是  | 字符串  | 商业 IMessage 应用程序名称  | 
|  |  bid  | 是  | 字符串  | 商业 IMessage 应用程序出价。模式：com.apple.messages。 MSMessageExtensionBalloonPlugin: \$1team-id\$1: \$1\$1 ext-bundle-id  | 
|  |  dataUrl  | 是  | 字符串  | 传递到 iMessage 应用程序的数据  | 
|  |  useLiveLayout  | 否  | 布尔值  | 默认：True  | 
|  |  title  | 是  | 字符串  | Imessage 应用程序泡沫的标题  | 
|  |  subtitle  | 否  | 字符串  | 副标题应用程序泡沫的标题  | 
|  replyMessage  |  title  | 否  | 字符串  |  | 
|  |  subtitle  | 否  | 字符串  |  | 
|  |  imageType  | 否  | 字符串  | 必须是可公开访问的有效 URL  | 
|  |  imageData  | 否  | 字符串  | 没有图像就不存在  | 

## WhatsApp 名单
<a name="whatsapp-list"></a>

**注意**  
您只能将此模板用于 WhatsApp 消息流。有关 WhatsApp 与 Amazon Connect 集成的更多信息[设置 WhatsApp 企业消息](whatsapp-integration.md)，请参阅本指南前面的。

您可以在 WhatsApp 聊天中使用 WhatsApp 列表模板为客户提供选项列表。

以下示例显示了用于银行服务的选项列表。

```
{
  "templateType": "WhatsAppInteractiveList",
  "version": "1.0",
  "data": {
    "content": {
      "title": "Which account do you need help with?",
      "body": {
        "text": "Which account do you need help with?"
      },
      "action": {
        "button": "Options",
        "sections": [
          {
            "title": "Your accounts",
            "rows": [
              {
                "id": "11111111",
                "title": "11111111",
                "description": "PERSONAL CHECKING"
              },
              {
                "id": "22223333",
                "title": "22223333",
                "description": "PERSONAL SAVINGS"
              }
            ]
          },
          {
            "title": "Other",
            "rows": [
              {
                "id": "other",
                "title": "I can't find my account"
              }
            ]
          }
        ]
      }
    }
  }
}
```

下图显示了客户打开列表之前和之后的典型屏幕。

![\[显示选项列表的图片。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/whatsapp-options-results.png)


### WhatsApp 期权限制
<a name="whatsapp-options-limits"></a>


| 父字段 | 字段 | 必需 | 最小长度  | 最大长度  | 其他要求 | 
| --- | --- | --- | --- | --- | --- | 
|  | templateType | 是 |  |  | 必须是 “WhatsAppInteractiveList” | 
|  | data | 是 |  |  |  | 
|  | 版本 | 是 |  |  | 必须为“1.0" | 
| data | content | 是 |  |  |  | 
| content | title | 是 |  |  |  | 
|  | 标题 | 否 |  |  |  | 
|  | body | 是  |  |  |  | 
|  | 页脚 | 否 |  |  |  | 
|  | action | 是 |  |  |  | 
| 标题 |  type  | 是  |  |  |  必须是“文本”  | 
|  |  文本  | 是  | 1  |  60  |  | 
| body |  文本  | 是  | 1 |  4096  |  | 
|  footer  |  文本  | 是  | 1 |  60  |  | 
|  action  |  章节  | 是  | 1 |  10  |  | 
|  |  按钮  | 是  | 1 |  20  |  | 
|  部分  |  title  | 是  | 1 |  24  |  | 
|  |  行  | 是  | 1 |  10  |  所有部分最多 10 行  | 
|  行  |  id  | 是 | 1 | 200 | 在行中必须唯一 | 
|  |  title  | 是  | 1 | 24 |  | 
|  | 描述 | 否  | 1 |  72  |  | 

## WhatsApp 回复按钮
<a name="whatsapp-reply-button"></a>

**注意**  
您只能将此模板用于 WhatsApp 消息流。

您可以使用 WhatsApp 回复按钮模板为客户提供内联选项列表。

```
{
  "templateType": "WhatsAppInteractiveReplyButton",
  "version": "1.0",
  "data": {
    "content": {
      "title": "What would you like to do?",
      "body": {
        "text": "What would you like to do?"
      },
      "action": {
        "buttons": [
          {
            "type": "reply",
            "reply": {
              "id": "agent",
              "title": "Continue to agent"
            }
          },
          {
            "type": "reply",
            "reply": {
              "id": "end_chat",
              "title": "End chat"
            }
          }
        ]
      }
    }
  }
}
```

下图显示了典型的用户体验。

![\[在聊天会话中回复的图像。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/whatsapp-reply-template.png)


### WhatsApp 回复按钮限制
<a name="whatsapp-reply-limits"></a>

回 WhatsApp 复模板有以下限制。


| 父字段 | 字段 | 必需 | 最小长度 | 最大长度  | 其他要求 | 
| --- | --- | --- | --- | --- | --- | 
|  | templateType  | 是 |  |  | 必须是 “WhatsAppInteractiveReplyButton”  | 
|  | data  | 是 |  |  |  | 
|  | 版本  | 是 |  |  | 必须为“1.0" | 
|  data  | content | 是 |  |  |  | 
|  content  | 标题 | 是 |  |  |  | 
|  | 标题 | 否 |  |  |  | 
|  | body | 是 |  |  |  | 
|  | footer  | 否 |  |  |  | 
|  | action  | 是 |  |  |  | 
| 标题  | type  | 是 |  |  | 有效值：“text”、“document”、“image”、“video”  | 
|  | 文本 | 否 | 1 | 60  |  | 
|  | 图片 | 否 |  |  |  | 
|  | 视频 | 否 |  |  |  | 
|  | 文档 | 否 |  |  |  | 
| 图片 | link  | 是 |  |  | 必须是可公开访问的媒体 URL，以 https/http 开头  | 
| 视频 | link  | 是 |  |  | 必须是可公开访问的媒体 URL，以 https/http 开头  | 
| 文档 | link  | 是 |  |  | 必须是可公开访问的媒体 URL，以 https/http 开头  | 
| body  | 文本  | 是 | 1 | 1024  |  | 
| footer  | 文本  | 是 | 1 | 60  |  | 
| action  | 按钮  | 是 | 1 | 3  |  | 
| 按钮  | type  | 是 |  |  | 必须是“reply”  | 
|  | reply.id | 是 | 1 | 256  | 各个按钮必须是唯一的  | 
|  | reply.title  | 是 | 1 | 20  |  | 

## 丰富的标题和字幕格式
<a name="rich-link-formatting"></a>

您可以为聊天消息的标题和副标题添加丰富的格式。例如，您可以添加链接、斜体、粗体、编号列表和项目符号列表。您可以使用 [markdown]( https://commonmark.org/help/) 设置文本格式。

下图的聊天框显示了标题和副标题中格式丰富的列表选择器示例。
+ 标题**我们该怎么帮您？aws.amazon.com** 以粗体显示，包含一个链接。
+ 副标题包含斜体和粗体文本、项目符号列表和编号列表。它还显示了纯链接、文本链接和示例代码。
+ 聊天框的底部显示了三个列表选择器元素。

![\[聊天框，带链接的标题，带有列表和链接的副标题。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/rich-link-formatting-example1a.png)


### 如何使用 markdown 设置文本格式
<a name="markdown-formatting-text"></a>

您可以用多行格式编写标题和副标题字符串，也可以在单行中使用 ``\r\n`` 换行符。
+ **多行格式**：以下代码示例说明了如何在 markdown 中以多行格式创作列表。

  ```
  const MultiLinePickerSubtitle = `This is some *emphasized text* and some **strongly emphasized text**
  
  This is a bulleted list (multiline):
  * item 1
  * item 2
  * item 3
  
  This is a numbered list:
  1. item 1
  2. item 2
  3. item 3
  
  Questions? Visit https://plainlink.com/faq
  
  [This is a link](https://aws.amazon.com)
  
  This is \`\`
  `
  
  const PickerTemplate = {
      templateType: "ListPicker|Panel",
      version: "1.0",
      data: {
          content: {
              title: "How can we help?",
              subtitle: MultiLinePickerSubtitle,
              elements: [ /* ... */ ]
          }
      }
  }
  ```
+ **单行格式**：以下示例说明了如何使用 ``\r\n`` 换行符在单行中创作副标题。

  ```
  const SingleLinePickerSubtitle = "This is some *emphasized text* and some **strongly emphasized text**\r\nThis is a bulleted list:\n* item 1\n* item 2\n* item 3\n\nThis is a numbered list:\n1. item 1\n2. item 2\n3. item 3\n\nQuestions? Visit https://plainlink.com/faq\r\n[This is a link](https://aws.amazon.com)\r\nThis is `<code/>`";
  
  const PickerTemplate = {
      templateType: "ListPicker|Panel",
      version: "1.0",
      data: {
          content: {
              title: "How can we help?",
              subtitle: SingleLinePickerSubtitle,
              elements: [ /* ... */ ]
          }
      }
  }
  ```

以下示例显示了如何使用 markdown 设置斜体和粗体文本的格式：

`This is some *emphasized text* and some **strongly emphasized text**`

以下示例显示了如何使用 markdown 将文本格式化为代码：

`This is `<code />``

### 如何使用 markdown 设置链接格式
<a name="markdown-formatting-links"></a>

要创建链接，请使用以下语法：

 `[aws](https://aws.amazon.com)`

以下示例显示了两种使用 markdown 添加链接的方法：

`Questions? Visit https://plainlink.com/faq `

`[This is a link](https://aws.amazon.com)`

**注意**  
对于列表选取器，如果您想对打开链接的位置进行精细控制，可以将 `targetForLinks` 字段作为子字段添加到 `content` 中。默认情况下，通信小部件将在新的浏览器选项卡中打开链接。有关更多信息，请参阅 [列表选择器模板](#list-picker)。