Ask Bar Widget

The Ask Bar widget adds a text box with a sparkle icon, floating at the bottom centre of your pages. When a customer types a question and submits it, the Genius Chat Widget opens with their question as their first message, so your flow can pick up the conversation.

Prerequisites

  • Your DigitalGenius widget ID.
  • Your region: eu or us.
  • The Genius Chat Widget on the same page. The widget opens the chat to send the customer's question. See Integrating Genius Chat Widget.
  • A flow that responds to conversations started from the widget. See Predefined message.
  • Access to edit the HTML of the page the widget is displayed on.

Installation

Add the following code to your page, after the Genius Chat Widget. Replace your-widget-id with your widget ID, and update env to match your region if required.

<script>
  window.DG_SDK_CONFIG = {
    components: [
      {
        widgetId: 'your-widget-id',
        env: 'eu',
        type: 'askBar',
      },
    ],
  };
</script>
<script src="https://chat.digitalgenius.com/init-sdk.js"></script>

The bar is docked to the bottom of the page, so it doesn't need a container. targetDOMNode isn't used.

Configuration

The following properties are set on each entry in components.

PropertyTypeRequiredDescription
widgetIdstringYesYour DigitalGenius widget ID.
envstringYesYour region: 'eu', 'us', or 'dev.us'.
typestringYesMust be 'askBar'.
config.langobjectNoOverrides the widget's text. See Customising text.
config.style.backgroundColorstringNoThe bar's background colour. Defaults to your page's background colour.
config.style.textColorstringNoThe colour of the text, the sparkle and the send button. Defaults to black, or white on a dark background.
config.style.accentColorstringNoThe colour the border fades from. Defaults to your site's brand colour, taken from the buttons and links on the page.
config.style.borderColorstringNoA single border colour, in place of the faded border.
config.style.bottomstringNoThe distance from the bottom of the screen, as any CSS length, for example '32px'. Defaults to 1.5em.
config.style.radiusstringNoThe corner radius of the bar, as any CSS length, for example '12px'. Defaults to fully rounded ends.
config.style.maxWidthstringNoThe maximum width of the bar, as any CSS length, for example '400px'. Defaults to 460px. On narrow screens the bar is never wider than the screen, less a small margin either side.

Localisation

The widget is displayed in British English by default. To change the language, set locale in your configuration:

window.DG_SDK_CONFIG = {
  locale: 'fr-FR',
  components: [
    {
      widgetId: 'your-widget-id',
      env: 'eu',
      type: 'askBar',
    },
  ],
};

The following locales are supported: ca-ES, 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 the app's config. Only the properties you specify are overridden; all other text uses the default wording for the selected locale.

config: {
  lang: {
    placeholder: 'Ask about sizing, delivery or returns',
  },
},
PropertyDefault (en-GB)Location
placeholderAsk anythingThe text shown in the box before the customer types.
inputLabelAsk a questionThe label of the text box, read out by screen readers.
sendSendThe label of the send button, read out by screen readers.

The customer's question is sent exactly as they typed it, as a predefinedMessage with context.source set to ask_bar and context.action set to free_text, and the page's address in context.data.url:

{
  "from": "customer",
  "type": "predefinedMessage",
  "payload": "Do these run true to size?",
  "context": {
    "source": "ask_bar",
    "action": "free_text",
    "data": { "url": "https://example.com/" }
  }
}

Behaviour

  • Loading: the bar slides up into place at the bottom of the screen as soon as the widget loads.
  • Position: the bar stays in place as the customer scrolls, and appears behind the chat widget when it's open. If you also use the Ask AI widget's floating button, it sits in the same place, so use one or the other.
  • Submitting: pressing Enter or clicking the send button opens the chat widget and sends the question as the customer's first message, then clears the box. If the Genius Chat Widget hasn't loaded, nothing is sent, the question stays in the box and a warning is logged to the browser console.
  • Send button: disabled while the bot is replying. If the box is empty, clicking it does nothing.
  • Focus: when the box has focus, a soft glow appears around the bar.
  • Reduced motion: if a customer's device is set to reduce motion, the bar doesn't slide in.

Styling

The widget renders inside a shadow DOM, so the styles on your page don't affect it. To change the colours, shape, width or position, use config.style:

config: {
  style: {
    accentColor: '#0f9d58',
    radius: '12px',
    maxWidth: '480px',
    bottom: '32px',
  },
},

Troubleshooting

If the bar does not appear, check that type is set to 'askBar', widgetId is correct and env matches your region.

If submitting a question does nothing, check that the Genius Chat Widget is on the page and loads without errors. A warning is logged to the browser console when it isn't available.


Did this page help you?