Skip to content
Cosmo

Docs · preview

Install your mascot

One script tag puts a living character on any website. This is a preview: names and details may change before launch.

The hosted script and dashboard aren't live yet. The mascot on this site runs the same widget in demo mode, so the API buttons below work right here.

1. Install

Paste this just before </body> on every page. Your SITE_ID is in the dashboard under Install.

HTML
<script src="https://cdn.YOUR-PRODUCT-DOMAIN.com/w.js"
        data-site="SITE_ID" async></script>
  • • It loads with the page at under 20 KB. The 3D character and the chat load only when needed.
  • • It renders inside a Shadow DOM, so your CSS can't break it and it can't break your site.
  • • Character, colours, greeting and knowledge come from your dashboard, so you never edit the snippet again.

2. Make it page-aware (optional)

Set selectors in the dashboard, or add these attributes to your HTML:

HTML
<!-- Where the mascot sits big on your homepage (desktop) -->
<div data-cosmo-hero style="width: 460px; aspect-ratio: 10 / 11"></div>

<!-- Sections it points at and comments on (once per visit) -->
<section data-cosmo-section="services">…</section>

<!-- What it says when this exact element is hovered -->
<article data-cosmo-say="Websites: fast, modern sites that bring in enquiries.">…</article>

3. JavaScript API

Once loaded, the widget exposes window.Mascot and fires a mascot:ready event on window.

JavaScript
// Open the chat (optionally straight into a mode)
Mascot.open();
Mascot.open({ kind: "demo", industry: "Clinic" });   // live AI front-desk demo
Mascot.open({ kind: "stump" });                      // "Stump me" challenge
Mascot.open({ kind: "send", text: "I'd like a quote" });

Mascot.close();
Mascot.say("New: weekend appointments!");            // a thought cloud above its head

// Listen for events; on() returns a function that stops listening
const off = Mascot.on("lead", (lead) => analytics.track("lead"));

// Switch character, colour or name on the fly
Mascot.setCharacter("miso", { accent: "#ec6aa0", name: "Mochi" });
Mascot.open(action?)Opens the chat from the mascot's face. Optional action: stump, demo (with industry), pick, check, or send (with text).
Mascot.close()Closes the chat; the screen shrinks back into the face.
Mascot.say(text)Shows a short thought cloud (up to 240 characters).
Mascot.on(event, fn)Subscribes to an event and returns an unsubscribe function.
Mascot.setCharacter(id, options?)Switches to cosmo, miso, ollie, basil, medi or lumi, with an optional accent colour and name.

Try it on this page

4. Events

  • openThe chat opened.
  • closeThe chat closed.
  • messageThe visitor sent a message.
  • leadA lead was saved (name, email or phone captured).
  • characterThe character changed.

Events for forms on your own pages are planned.

5. Behaviour & accessibility

  • • Visitors who prefer reduced motion get a still launcher instead of a roaming character.
  • • Visitors on data-saver keep the light image and never download the 3D engine.
  • • It greets once per visit, every bubble can be dismissed, and “park me” keeps it in the corner.
  • • The chat is a proper dialog: keyboard focus stays inside, Escape closes it, and screen readers hear every message.
  • • It always says it's an AI assistant, with a privacy link reachable from the chat.