Base URLhttps://ottla.ai/api/v1

Guides

Install the widget

Copy and paste the two tags provided by your console, with a browser key locked to your storefront’s address.

Updated 9 min read

On this page

On a headless or custom storefront, the chat widget goes in with two script tags. The first, in the <head>, puts the launcher in place before the page paints, so nothing jumps. The second, before </body>, loads the widget itself. You do not write either by hand: the console’s Install button gives you both, filled in.

Add the widget

  1. Create an advisor

    Create an advisor under Storefront → Widgets and select its mode: chat (a floating launcher), sidebar or inline. You can set the colours and copy now or at a later date. Your tags do not change when you do this.

  2. Create a browser key

    In Storefront → API keys, create a Storefront widget key. It has only ask:read and feedback:write. Add your storefront’s address under Allowed origins, for example https://shop.example.

  3. Copy the snippet

    Click Install on the widget and copy what it shows. For a chat widget it looks like this, with your own widget id and website id. The console never puts a key in the snippet: the placeholder YOUR_BROWSER_KEY is there for you to replace.

    HTML
    <!-- Ottla: in the <head> of every page -->
    <script async src="https://ottla.ai/widget/ottla-bootstrap.min.js"
      data-widget-public-id="wgt_xxxxxxxxxxxxxxxxxxxx"
      data-website-id="12"
      data-mode="chat"
      data-position="bottom-right"></script>
    
    <!-- Ottla: before </body> on every page -->
    <script async src="https://ottla.ai/widget/loader.js"
      data-token="YOUR_BROWSER_KEY"
      data-widget-public-id="wgt_xxxxxxxxxxxxxxxxxxxx"
      data-website-id="12"></script>
  4. Paste both tags into every page

    Put the first tag in the <head> and the second just before </body> of every page, usually in your layout template, and replace YOUR_BROWSER_KEY with the Storefront widget key from step 2.

Install window in the Ottla console with the head and body script tags for a chat widget Example data

Sidebar and inline widgets

The Install button gives you the correct tags for each mode. Here’s what changes.

<!-- Ottla: in the <head> of every page -->
<script src="https://ottla.ai/widget/ottla-bootstrap.min.js"
  data-widget-public-id="wgt_xxxxxxxxxxxxxxxxxxxx"
  data-website-id="12"
  data-mode="sidebar"
  data-dock-side="right"
  data-dock-width="400"></script>

<!-- Ottla: before </body> on every page -->
<script async src="https://ottla.ai/widget/loader.js"
  data-token="YOUR_BROWSER_KEY"
  data-widget-public-id="wgt_xxxxxxxxxxxxxxxxxxxx"
  data-website-id="12"></script>

A sidebar head tag has no async. That is deliberate: it reserves the sidebar’s space before the page paints, so your layout does not shift when the widget arrives. It carries the side and width, and data-open="true" only when the sidebar opens by default.

An inline widget has no head tag at all. Put the <div> where the panel should appear and the loader tag after it.

Both tags always carry the same widget id and website id, because the two scripts use them to find each other. A widget that serves all your storefronts has no data-website-id: the key decides. The loader always loads the current build of the widget, so you never update the snippet when Ottla releases a new version.

Keys and allowed origins

The key in your pages must be a Storefront widget key, with only ask:read and feedback:write. Anyone can read it in your page source, which is fine for a key that can only do what your storefront does for a shopper. It cannot report orders or change your catalogue.

List every address shoppers use under Allowed origins: https://shop.example, with no path. For your own subdomains, one wildcard label such as https://*.shop.example works; a wildcard over a shared ending such as .co.uk is refused. A browser call with a key that has no allowed origins is refused with 403 origin_not_configured. API keys and allowed origins has every rule.

Content Security Policy

If you are using a Content Security Policy on your storefront, you need to allow:

CSP entries for a direct embed
Directive Allow Why
script-src https://ottla.ai The two widget scripts
connect-src https://ottla.ai The widget’s calls to the API
connect-src wss://*.ottla.ai Live chat messages in real time (Growth and above)
img-src https://ottla.ai Images the widget shows
media-src https://ottla.ai The reply chime
font-src Your font’s host Only if you choose a custom font hosted elsewhere

Note that https://*.ottla.ai does not cover https://ottla.ai itself, so list the address without the wildcard. Live chat is the one entry that needs a wildcard: it connects to a subdomain (chat-uk.ottla.ai for stores in the UK region), and wss://*.ottla.ai covers every region’s host.

Check it works

  1. Open the assistant on your storefront

    Load a page on your store and open your assistant. You’ll see the Place the advisor on your store step in Getting started tick once it’s been opened.

  2. Ask something you know the answer to

    Ask about a product’s weight, your returns policy or how much delivery is. These are all easy to verify.

  3. If nothing appears, open the browser console

    A 403 with origin_not_allowed or origin_not_configured means the address is missing from Allowed origins. A blocked script means a CSP entry is missing. A widget with an IP allow-list shows only to those addresses, and a widget whose Status is Draft (not served) shows to nobody.

A custom storefront with the Ottla chat open in the bottom right corner Example data
Shown on a demo store

FAQ

Frequently asked questions

Do I need to update the snippet when Ottla releases a new widget?

No. The loader always loads the latest version of our code, so the tags you pasted keep working.

Where do I find my widget id?

You don’t need to find this. The Install button populates it for you, as well as your website id.

Can I put two widgets on one page?

Yes. Two different widgets never clash. To show the same widget twice in the same mode, give each pair of tags its own data-instance-id, with the same value on both tags of a pair.

Why does the assistant not appear?

Most likely you’re missing an allowed origin or a CSP entry, have an IP allow-list on your widget, or your widget’s Status is set to Draft (not served). Your browser console tells you which.

Does it work on Magento without the module?

Use the Magento module. It adds the widget for you, keeps your catalogue in sync and adds search and product rows. Use the snippet if you have a headless or custom storefront.

Next

Try Ottla

Give every shopper a good answer.

Start your free trial on your own store, or book a demo and we’ll show you Ottla on a store like yours.

14 days free. No card needed.