|
| 1 | +# Hosted Widget Customizations |
| 2 | + |
| 3 | +Additional ways to configure the Amazon Connect Hosted Widget on your website and further personalize the branding. |
| 4 | + |
| 5 | +View the following sample code for customizing the widget. Follow the ["Admin Guide: Add chat to your website"](https://docs.aws.amazon.com/connect/latest/adminguide/add-chat-to-website.html) to get started, and replace the example snippets with your generated `<script>` code. |
| 6 | + |
| 7 | +```html |
| 8 | +<!-- EXAMPLE SNIPPET - Edit all "<REPLACE_ME>" values --> |
| 9 | +<script type="text/javascript"> |
| 10 | + (function (w, d, x, id) { |
| 11 | + s = d.createElement("script"); |
| 12 | + s.src = |
| 13 | + "https://<REPLACE_ME>.cloudfront.net/amazon-connect-chat-interface-client.js"; |
| 14 | + s.async = 1; |
| 15 | + s.id = id; |
| 16 | + d.getElementsByTagName("head")[0].appendChild(s); |
| 17 | + w[x] = |
| 18 | + w[x] || |
| 19 | + function () { |
| 20 | + (w[x].ac = w[x].ac || []).push(arguments); |
| 21 | + }; |
| 22 | + })(window, document, "amazon_connect", "<REPLACE_ME>"); |
| 23 | + amazon_connect("styles", { |
| 24 | + openChat: { color: "#ffffff", backgroundColor: "#07b62a" }, |
| 25 | + closeChat: { color: "#ffffff", backgroundColor: "#07b62a" }, |
| 26 | + }); |
| 27 | + // ALSO: further customize the widget styles: https://docs.aws.amazon.com/connect/latest/adminguide/pass-custom-styles.html |
| 28 | + amazon_connect("snippetId", "<REPLACE_ME>"); |
| 29 | + amazon_connect("supportedMessagingContentTypes", [ |
| 30 | + "text/plain", |
| 31 | + "text/markdown", |
| 32 | + ]); |
| 33 | + // ALSO: how to pass contact attributes: https://docs.aws.amazon.com/connect/latest/adminguide/pass-contact-attributes-chat.html |
| 34 | + amazon_connect('customerDisplayName', function(callback) { |
| 35 | + const displayName = '<REPLACE_ME>'; |
| 36 | + callback(displayName); |
| 37 | + }); |
| 38 | +</script> |
| 39 | +``` |
| 40 | + |
| 41 | +## Prerequisites |
| 42 | + |
| 43 | +Looking to add the Amazon Connect Widget to your website? Follow the [Admin Guide documentation](https://docs.aws.amazon.com/connect/latest/adminguide/add-chat-to-website.html) |
| 44 | + |
| 45 | +New to Amazon Connect Open Source? Follow the [open source walkthrough](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/blob/master/.github/docs/AmazonConnectChatOpenSourceWalkthrough.md) |
| 46 | + |
| 47 | +## Examples |
| 48 | + |
| 49 | +### Basic setup |
| 50 | + |
| 51 | +[basicWidgetSetup](./basicWidgetSetup): render Amazon Connect widget button in the lower-right corner of your website. |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +### Custom widget launch button |
| 56 | + |
| 57 | +[customWidgetLaunchButton](./customWidgetLaunchButton): launch the widget from a button element anywhere on your website. |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +### Custom floating widget launch icon |
| 62 | + |
| 63 | +[customFloatingWidgetLaunchIcon](./customFloatingWidgetLaunchIcon): launch the widget from a floating icon rendered anywhere on your website. |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +### Hyperlink support |
| 68 | + |
| 69 | +[hyperlinkSupportWidget](./hyperlinkSupportWidget): support a plain-text URL that launches the widget on page load. |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +### Load widget assets when button is clicked |
| 74 | + |
| 75 | +[loadAssetsOnButtonClick](./loadAssetsOnButtonClick): improve page load speed by only fetching widget static assets on button click, versus on page load. |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +### Launch a new chat in a browser window |
| 80 | + |
| 81 | +[launchChatBrowserWindow](./launchChatBrowserWindow): make the widget launch in a new browser window. |
| 82 | + |
| 83 | + |
0 commit comments