PAI Widget
The PAI widget embeds an inline widget within your product pages. Shoppers can ask a question or select a suggested prompt, and receive tailored guidance and product recommendations.
Prerequisites
- Your DigitalGenius widget ID.
- Your region:
euorus. - Access to edit the HTML of your product pages.
Installation
Add the following code to your product page, at the position where the widget should appear. Replace your-widget-id with your widget ID, and update env to match your region if required.
<div id="pai-widget"></div>
<script>
window.DG_SDK_CONFIG = {
widgetId: 'your-widget-id',
env: 'eu',
widget: {
targetDOMNode: '#pai-widget',
type: 'PAI',
config: {
buttonLabels: [
'What would you recommend?',
'Something for a gift',
'Show me similar products',
],
},
},
};
</script>
<script src="https://chat.digitalgenius.com/init-sdk.js"></script>The widget is rendered inside the <div id="pai-widget"></div> container.
Configuration
The following properties are set within the widget object.
| Property | Required | Description |
|---|---|---|
targetDOMNode | Yes | The container the widget is rendered in, referenced by its id with a # prefix, for example #pai-widget. |
type | Yes | Identifies the widget to load. Must be 'PAI'. |
config.buttonLabels | No | A list of suggested prompts, displayed as buttons. Selecting a prompt submits it as the shopper's question. If omitted, only the text input is displayed. |
config.showChatInput | No | Controls whether the text input is displayed. Defaults to true. Set to false to limit shoppers to the suggested prompts. |
Shopper experience
On load, the widget displays:
- The heading "Ask about this product".
- A text input for free-form questions.
- Any suggested prompts you have configured.
Once a shopper submits a question, the widget displays the conversation. Responses may include a product carousel, from which shoppers can browse and select one or more products.
Localisation
The widget is displayed in British English by default. To change the language, set locale in your configuration:
window.DG_SDK_CONFIG = {
widgetId: 'your-widget-id',
env: 'eu',
locale: 'fr-FR',
widget: {
targetDOMNode: '#pai-widget',
type: 'PAI',
},
};The following locales are supported: cs-CZ, da-DK, de-DE, en-GB, en-LU, en-US, es-ES, et-EE, fi-FI, fr-FR, it-IT, ja-JP, ko-KR, lt-LT, lv-LV, nl-NL, no-NO, pl-PL, pt-PT, ro-RO, sk-SK, sv-SE, zh-CN and zh-TW. Unsupported locales fall back to British English.
Customising text
The text listed below can be customised using a lang object in your configuration. Only the properties you specify are overridden; all other text uses the default wording for the selected locale.
window.DG_SDK_CONFIG = {
widgetId: 'your-widget-id',
env: 'eu',
lang: {
title: 'Find the right product',
askAQuestionPlaceholder: 'Tell us what you need',
},
widget: {
targetDOMNode: '#pai-widget',
type: 'PAI',
},
};Visible text
| Property | Default (en-GB) | Location |
|---|---|---|
title | Ask about this product | The widget heading. |
askAQuestionPlaceholder | Ask a question... | The placeholder text in the text input. |
carouselSelectionButtonText | Select | The button on each product card, where the flow does not define its own label. |
carouselMultiSelectButtonText | Confirm your selection | The button used to confirm a multi-product selection. |
For example, to adjust the product carousel buttons to suit your brand's tone of voice:
lang: {
carouselSelectionButtonText: 'Choose this',
carouselMultiSelectButtonText: 'Show my picks',
}Accessibility text
The following text is not displayed visually but is announced by screen readers. If you provide your own translations, we recommend including these properties to ensure an accessible experience.
| Property | Default (en-GB) | Announced |
|---|---|---|
askAQuestion | Ask a question | On the text input. |
send | Send | On the send button. |
promptButtonsLabel | Prompt buttons | On the group of suggested prompts. |
quickRepliesLabel | Suggested replies | On the group of quick reply buttons. |
conversationLabel | Conversation | On the conversation area. |
you | You | Before each shopper message. |
assistant | Assistant | Before each response. |
assistantTyping | Assistant is typing | While a response is being generated. |
carouselPrevious | Go to previous item | On the carousel's previous button. |
carouselNext | Go to next item | On the carousel's next button. |
Styling
By default, the widget inherits your page's font and text colour, and uses a transparent background, so it integrates with your existing design.
To customise its appearance, set any of the following CSS custom properties on the container. Only the properties you specify are overridden.
#pai-widget {
--dg-max-width: 28rem;
--dg-max-height: 24em;
--dg-radius: 16px;
--dg-panel-bg: #ffffff;
--dg-user-bg: #4a3428;
--dg-user-color: #f4efe6;
--dg-assistant-bg: #f4efe6;
--dg-assistant-color: #4a3428;
}| Property | Default | Description |
|---|---|---|
--dg-max-width | Full width of the container | The maximum width of the widget. |
--dg-max-height | 20em | The maximum height of the conversation before it scrolls. |
--dg-radius | 12px | The corner radius of the widget. |
--dg-panel-bg | Transparent | The widget's background colour. |
--dg-user-bg | Inherited text colour | The background colour of shopper messages and the send button. |
--dg-user-color | The browser's default background colour (white in light mode) | The text colour of shopper messages. |
--dg-assistant-bg | A light tint of the inherited text colour | The background colour of responses. |
--dg-assistant-color | Inherited text colour | The text colour of responses. |
Troubleshooting
If the widget does not appear, check that:
- The
<div id="pai-widget"></div>container is on the page and placed before the scripts. targetDOMNodematches the container's id, including the#prefix.typeis set to'PAI'.widgetIdis correct andenvmatches your region.
Updated about 1 hour ago
