Skip to content
Getting started

Installing the chat

The Otto chat goes on your website with one line of code. Here is where it goes, and how to set the language, a signed-in customer, cookie consent and CSP.

On this page

The chat code

In the panel open Overview, the Installation & integrations card, click Custom code and then Copy code. You get one line with your company’s public key:

<script async src="https://ottoai.sk/widget.js" data-otto-key="pk_vas_kluc"></script>
The Installation and integrations card in the Otto panel with the chat code
The chat code in the panel: Overview, Installation & integrations, Custom code.

Put it into your website template right before </body>, ideally in the shared footer every page uses. The script loads asynchronously and does not slow down rendering.

The public key pk_… is not a password, you do not need to hide it. It only tells Otto whose visitors to answer. The chat also only answers on the domain where you first launched it. If you need it on another domain, write to us. Only the API key is secret, and it never goes into website code.

Where it goes

For Shoptet, WordPress, Shopify, Upgates and dozens more systems such as PrestaShop, Wix or Webflow, follow the step-by-step guides in Platform guides. On a custom website or another system, look in the admin for a place for custom footer code, usually called Footer code, Custom HTML or Footer. Add it once, not on every page.

Chat language

By default the chat speaks the language set in the panel. If your website has several language versions, give each one its language with data-otto-lang set to sk, cs or en:

<script async src="https://ottoai.sk/widget.js" data-otto-key="pk_vas_kluc" data-otto-lang="en"></script>

Signed-in customers

When a customer is signed in on your website, you can tell the chat who they are. Your colleague then sees their name and email with the conversation, and Otto does not have to ask. Either add the data-otto-name, data-otto-email and data-otto-phone attributes, or set window.ottoUser before the chat code:

<script>
  window.ottoUser = { name: "Jane Smith", email: "jane@example.com", phone: "+441234567890" };
</script>
<script async src="https://ottoai.sk/widget.js" data-otto-key="pk_vas_kluc"></script>
Only output these details for the signed-in customer, and keep that page out of any cache, or the next visitor would see them. Never put personal data into the page URL. The WordPress plugin handles this for you.

Verified customers

Anyone can overwrite the name and email in window.ottoUser on the page. To be sure it really is the signed-in customer, turn on the Verified customer card in the panel under Settings, Connections. The panel creates a secret your server uses to sign a short token, and your site passes it to the chat:

<script>
  window.ottoUser = { token: "TOKEN_FROM_YOUR_SERVER" };
</script>
<script async src="https://ottoai.sk/widget.js" data-otto-key="pk_vas_kluc"></script>

You can also put the token in the data-otto-token attribute of the chat code. It is a JWT signed with HS256. sub, your ID of the customer, and exp, an expiry at most 30 days ahead, are required. email, name and phone are optional. You can create the token without a library:

Node.js
import crypto from "node:crypto";

const b64 = (x) => Buffer.from(JSON.stringify(x)).toString("base64url");

export function tokenPreOtta(zakaznik) {
  const hlavicka = b64({ alg: "HS256", typ: "JWT" });
  const obsah = b64({
    sub: String(zakaznik.id),
    email: zakaznik.email,
    name: zakaznik.meno,
    exp: Math.floor(Date.now() / 1000) + 24 * 3600,
  });
  const podpis = crypto.createHmac("sha256", process.env.OTTO_IDENTITA)
    .update(hlavicka + "." + obsah).digest("base64url");
  return hlavicka + "." + obsah + "." + podpis;
}
PHP
function tokenPreOtta(array $zakaznik): string {
  $b64 = fn($x) => rtrim(strtr(base64_encode($x), '+/', '-_'), '=');
  $hlavicka = $b64(json_encode(['alg' => 'HS256', 'typ' => 'JWT']));
  $obsah = $b64(json_encode([
    'sub' => (string) $zakaznik['id'],
    'email' => $zakaznik['email'],
    'name' => $zakaznik['meno'],
    'exp' => time() + 24 * 3600,
  ]));
  $podpis = $b64(hash_hmac('sha256', $hlavicka . '.' . $obsah, getenv('OTTO_IDENTITA'), true));
  return $hlavicka . '.' . $obsah . '.' . $podpis;
}
Python
import os, time
import jwt  # pip install PyJWT

def token_pre_otta(zakaznik):
    return jwt.encode(
        {"sub": str(zakaznik["id"]), "email": zakaznik["email"], "name": zakaznik["meno"],
         "exp": int(time.time()) + 24 * 3600},
        os.environ["OTTO_IDENTITA"], algorithm="HS256")

What changes then:

  • The conversation in the panel gets a Verified badge and your ID of the customer. The name and email from the token take precedence over those from window.ottoUser.
  • A signed-in customer’s chat opens only with a token for that same customer. When someone else signs in on the same device, or the customer signs out, the chat starts a new conversation.
  • The API returns customerId with each conversation and customer in the detail, and the conversation.started and lead.created webhooks carry customer.
  • Otto’s answers do not change.
To see whether the token passed, look at the x-otto-identita header of the /api/chat request in your browser’s developer tools: overena, or a reason such as exp or podpis. With an invalid token the chat carries on as for a signed-out visitor and says why in the browser console.
The secret belongs on your server only, never in page or app code. If it leaks, click New secret in the card. Tokens signed with the old one stop working.

Cookie consent

Before the visitor consents, Otto stores nothing in the browser. It remembers the conversation only once the customer opens the chat or writes in it. It stores the number of visits, the first visit and the pages visited for your colleagues in the panel only with consent to statistics or analytics.

Otto recognises consent on its own from these banners:

  • Shoptet: consent to analytics cookies,
  • Complianz (WordPress): consent to statistics,
  • Cookiebot: consent to statistics,
  • CookieYes: consent to analytics cookies.

If you use a different banner, add data-otto-suhlas with the name and value of the entry your banner stores when statistics are accepted. Otto looks for it in localStorage and in cookies:

<script async src="https://ottoai.sk/widget.js" data-otto-key="pk_vas_kluc" data-otto-suhlas="analytics_cookies=yes"></script>

If you leave out the value after the equals sign, Otto expects ano. Without consent the chat works normally, it only sends the current page and the browser language, and the visitor does not appear among Visitors in the panel.

Content-Security-Policy

If your website sends a Content-Security-Policy header, allow Otto’s domain for scripts and connections, including the WebSocket. If you also restrict images, add ottoai.sk, data: and the domain your product images come from.

Content-Security-Policy
script-src  'self' https://ottoai.sk;
connect-src 'self' https://ottoai.sk wss://ottoai.sk;
img-src     'self' data: https://ottoai.sk https://images.your-shop.com;

The chat adds its styles through the CSSOM into its own Shadow DOM, so you do not need to change style-src, and your website styles do not affect the chat.

Checking it works

  1. Open your website and reload. A chat bubble should pop up in the bottom right.
  2. In the panel, Settings, Connections, the Your website row shows the domain the chat runs on.
  3. To try it without your website, use Try it as a customer in Settings.
No chat? Check that the code is not added twice (the second one is ignored), that a script optimiser does not strip it, and that your CSP allows it. Look for console messages starting with [Otto].

Single-page apps

In React, Vue or Next.js apps, add the code once to the main template, not to a component that renders again. The chat starts once and keeps running when the URL changes without a reload.