

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

# 针对您的 Amazon Connect 聊天小部件的额外自定义
<a name="pass-customization-object"></a>

您可在聊天用户界面中添加以下可选自定义设置：
+ 在标题下拉菜单中而不是页脚中显示**结束聊天**按钮。
+ 屏蔽或隐藏显示名称。
+ “添加消息”图标。
+ 覆盖事件消息。
+ 配置一个确认对话框，当客户选择**结束聊天**按钮时，该对话框将呈现给客户。该对话框验证客户是否确实打算结束聊天会话。您可以自定义确认对话框、标题、消息和按钮文本。
+ 覆盖拒绝附件消息。

## 配置自定义设置对象
<a name="configure-customization-object"></a>

此示例演示如何实现一些可选的自定义设置。有关所有可能的自定义功能的列表，请参阅 [支持的选项和限制](#customization-options-constraints)。由于这些自定义功能是可选的，因此您可以实现以下示例中显示的部分或全部字段。根据需要替换 `eventNames.customer`、`eventNames.agent`、`eventNames.supervisor`、`eventMessages.participantJoined`、`eventMessages.participantDisconnect`、`eventMessages.participantLeft`、`eventMessages.participantIdle`、`eventMessages.participantReturned` 和 `eventMessages.chatEnded` 字符串。图标必须公开托管 URLs。

```
amazon_connect('customizationObject', {
        header: { 
            dropdown: true, 
            dynamicHeader: true,
        },
        transcript: { 
            hideDisplayNames: false, 
            eventNames: {
                customer: "User",
                agent: "Webchat Agent",
                supervisor: "Webchat Supervisor"
            },
            eventMessages: {
                participantJoined: "{name} has joined the chat",
                participantDisconnect: "",
                participantLeft: "{name} has dropped",
                participantIdle: "{name}, are you still there?",
                participantReturned: "",
                chatEnded: "Chat ended",
            },
            displayIcons: true,
            iconSources: { 
                botMessage: "imageURL",
                systemMessage: "imageURL",
                agentMessage: "imageURL",
                customerMessage: "imageURL",
            },
        },
        composer: {
            disableEmojiPicker: true,
            disableCustomerAttachments: true,
            alwaysHideToolbar: true,
            hide: false,
        },
        footer: {
            disabled:true,
            skipCloseChatButton: true,
        },
        endChat: {
            enableConfirmationDialog: true,
            confirmationDialogText: {
                title: "End Chat",
                message: "Are you sure you want to end this chat?",
                confirmButtonText: "End Chat",
                cancelButtonText: "Cancel",
        },
    },
    attachment: {
         // Default rejectedErrorMessage: Attachment was rejected.
        rejectedErrorMessage: "Custom Error Message: Files cannot exceed 15 MB." //this is customizable attribute 
    }
});
```

下图显示了使用示例时自定义设置的外观：

![\[示图显示可自定义的显示名称、菜单位置、图标以及“结束聊天”确认对话框。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/chat-customization-diagram2.png)


## 支持的选项和限制
<a name="customization-options-constraints"></a>

下表列出了支持的自定义设置字段和推荐的值限制。


| 自定义布局选项 | Type | 描述 | 
| --- | --- | --- | 
|  `header.dropdown`  |  布尔值  |  呈现标题下拉列表而不是默认页脚  将此选项设置为 `true` 时，将显示**脚本下载**按钮并保持可见状态，直到您将该选项设置为 `false` 或删除该选项。   | 
| `header.dynamicHeader` | 布尔值 | 将标题动态设置为 “与 Bot/ 聊天AgentName”。 | 
| `header.hideTranscriptDownloadButton` | 布尔值 | 隐藏标题下拉菜单中的[下载文字记录](chat-widget-download-transcript.md)按钮。默认值为 false。 | 
|  `transcript.hideDisplayNames`  |  布尔值  |  隐藏所有显示名称，如果未提供 `eventNames`，将应用默认名称掩码。  | 
|  `transcript.eventNames.customer`  |  字符串  |  屏蔽客户的显示名称。  | 
|  `transcript.eventNames.agent`  |  字符串  |  屏蔽座席的显示名称。  | 
|  `transcript.eventNames.supervisor`  |  字符串  |  屏蔽主管的显示名称。  | 
|  ` transcript.eventMessages.participantJoined`  |  字符串  |  当有参与者加入聊天时，覆盖转录中的事件消息。如果指定空字符串，则转录中将省略事件消息。可以在消息中传递 `{name}`，并将被替换为相应参与者的显示名称。默认消息是 `{name} has joined the chat`。  | 
|  `transcript.eventMessages.participantDisconnect`  |  字符串  |  当有参与者从聊天中断开连接时，覆盖转录中的事件消息。如果指定空字符串，则转录中将省略事件消息。可以在消息中传递 `{name}`，并将被替换为相应参与者的显示名称。默认消息是 \$1`name} has been idle too long, disconnecting`。  | 
|  `transcript.eventMessages.participantLeft`  |  字符串  |  当有参与者离开聊天时，覆盖转录中的事件消息。如果指定空字符串，则转录中将省略事件消息。可以在消息中传递 `{name}`，并将被替换为相应参与者的显示名称。默认消息是 `{name} has left the chat`。  | 
|  `transcript.eventMessages.participantIdle`  |  字符串  |  当有参与者处于空闲状态时，覆盖转录中的事件消息。如果指定空字符串，则转录中将省略事件消息。可以在消息中传递 `{name}`，并将被替换为相应参与者的显示名称。默认消息是 `{name} has become idle`。  | 
|  `transcript.eventMessages.participantReturned`  |  字符串  |  当有参与者返回聊天时，覆盖转录中的事件消息。如果指定空字符串，则转录中将省略事件消息。可以在消息中传递 `{name} `，并将被替换为相应参与者的显示名称。默认消息是 `{name} has returned`。  | 
|  `transcript.eventMessages.chatEnded`  |  字符串  |  当聊天结束时，覆盖转录中的事件消息。如果指定空字符串，则转录中将省略事件消息。可以在消息中传递 `{name}`，并将被替换为相应参与者的显示名称。默认消息是 `Chat has ended!`  | 
|  `transcript.displayIcons`  |  布尔值  |  启用消息显示图标。  | 
|  `transcript.iconSources.botMessage`  |  字符串  |  为机器人消息显示的图标，必须托管在公共 URL 上。  | 
|  `transcript.iconSources.systemMessage`  |  字符串  |  为系统消息显示的图标，必须托管在公共 URL 上。  | 
|  `transcript.iconSources.agentMessage`  |  字符串  |  为座席消息显示的图标，必须托管在公共 URL 上。  | 
|  `transcript.iconSources.customerMessage`  |  字符串  |  为客户消息显示的图标，必须托管在公共 URL 上。  | 
|  `composer.alwaysHideToolbar`  |  布尔值  |  隐藏格式工具栏，该工具栏包含文本样式功能，例如粗体、斜体以及项目符号列表和编号列表选项。  | 
|  `composer.disableEmojiPicker`  |  布尔值  |  使用[富文本编辑器](enable-text-formatting-chat.md)时禁用表情符号选择器。  | 
| `composer.disableCustomerAttachments` | 布尔值 | 防止客户发送或上传附件。 | 
| `composer.hide` | 布尔值 | 隐藏作曲家 (`true`) 或显示它 (`false`)。要根据事件（例如代理加入时）切换作曲器，请`registerCallback`与`hideComposer`方法一起使用。有关更多信息，请参阅 [Amazon Connect 中支持可自定义的小部件片段字段](supported-snippet-fields.md)。<pre>document.getElementById("amazon-connect-chat-widget-iframe").contentWindow.connect.ChatInterface.hideComposer(false)</pre> | 
|  `footer.disabled`  |  布尔值  |  隐藏默认页脚和**结束聊天**按钮。  | 
|  `footer.skipCloseChatButton`  |  布尔值  |  单击**结束聊天**按钮时直接关闭小部件，而不是显示**关闭**按钮。  | 
| `endChat.enableConfirmationDialog` | 布尔值 | 启用“结束聊天”确认对话框。如果未提供 confirmationDialogText，则使用默认文本。 | 
| `endChat.confirmationDialogText.title` | 字符串 | 覆盖“结束聊天”确认对话框的标题。 | 
| `endChat.confirmationDialogText.message` | 字符串 | 覆盖“结束聊天”确认对话框的消息。 | 
| `endChat.confirmationDialogText.confirmButtonText` | 字符串 | 覆盖“结束聊天”确认对话框中的“确认”按钮文本。 | 
| `endChat.confirmationDialogText.cancelButtonText` | 字符串 | 覆盖“结束聊天”确认对话框中的“取消”按钮文本。 | 
| `attachment.rejectedErrorMessage` | 字符串 | 覆盖聊天小部件附件被拒绝的错误消息。 | 