

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

# 在聊天中为客户添加 Amazon Lex 互动消息
在聊天中添加交互式消息

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

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

## 验证限制
验证限制

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

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

## 消息显示模板
消息显示模板

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)

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

## 列表选择器模板


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

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

![\[列表选择器模板在聊天中呈现信息。\]](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"
            }
         ]
      }
```

### 列表选择器限制


如果您选择从头开始构建自己的 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')                                       
```

## 时间选取器模板


时间选取器模板非常有用，能让客户安排预约。您最多可以在聊天中向客户提供 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,                              
               }
            ],           
         }
      }
   }
}
```

### 时间选取器限制


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


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

## 面板模板


通过使用面板模板，您可以在一个问题下向客户提供最多 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",                    
            }
         ]
      }
   }
}
```

### 面板限制


如果您选择从头开始构建自己的 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)

## 快速回复模板


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

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

![\[面板模板在聊天中呈现信息。\]](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"
                }
            ]
        }
    }
}
```

### 快速回复限制


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


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

## 轮播模板


使用轮播在一条消息中向客户显示最多 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"
  }
  ```

### 轮播限制


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


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

## Apple 表单模板
Apple 表单模板

**注意**  
 此模板仅适用于 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 表单限制
Apple 表单限制

#### InteractiveMessage



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

#### InteractiveMessageData



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

#### AppleFormContent



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

#### AppleFormSplashPage



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

#### AppleFormPage

+  表单页面基本模型。从此模型延伸出的特定页面类型 


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

#### AppleFormDatePickerPage


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


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

#### AppleFormListPickerPage


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


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

#### AppleFormListPickerPageItem


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


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

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

#### AppleFormWheelPickerPage


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


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

#### AppleFormWheelPickerPageItem


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


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

#### AppleFormInputPage


 **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 模板
Apple Pay 模板

**注意**  
此模板仅适用于 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 限制
Apple Pay 限制


| 父字段  | 字段  | 必需  | 最少字符  | 最多字符  | 其他要求  | 
| --- | --- | --- | --- | --- | --- | 
|  | 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 应用程序模板
iMessage 应用程序模板

**注意**  
此模板仅适用于 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 应用程序限制
iMessage 应用程序限制


|  **父字段**  |  **字段**  |  **必填**  |  **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 名单


**注意**  
您只能将此模板用于 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 期权限制



| 父字段 | 字段 | 必需 | 最小长度  | 最大长度  | 其他要求 | 
| --- | --- | --- | --- | --- | --- | 
|  | 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 回复按钮


**注意**  
您只能将此模板用于 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 回复按钮限制


回 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  |  | 

## 丰富的标题和字幕格式
丰富的标题和字幕格式

您可以为聊天消息的标题和副标题添加丰富的格式。例如，您可以添加链接、斜体、粗体、编号列表和项目符号列表。您可以使用 [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 设置文本格式
Markdown 格式化

您可以用多行格式编写标题和副标题字符串，也可以在单行中使用 ``\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 设置链接格式
Markdown 链接

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

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

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

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

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

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