Aimigo

Web pages

Embed and JavaScript API

Every attribute of the script tag, every function of window.Aimigo, and the events your page receives.

The script tag

<script src="https://player.aimigo.live/embed/aimigo-embed.js"
        data-character="Ben" data-mode="transparent" data-position="bottom-right"></script>

All attributes are optional.

AttributeValuesDefaultMeaning
data-charactercharacter name, id or slotBencharacter loaded at start
data-modetransparent, roomtransparenttransparent stage over your page, or a 3D room
data-scenescene iddefault room3D room for data-mode="room"
data-layoutauto, overlay, window, fullscreen, cornerautohow the player sits on the page, see layouts
data-positionbottom-right, bottom-left, top-right, top-leftbottom-rightcorner of the frame in layout corner
data-width, data-heightCSS sizesmin(34vw,420px), min(62vh,620px)size of the frame in layout corner (setting one of them selects corner)
data-targetCSS selector–put the player into this element (it fills it) instead of a floating corner
data-interactivemask, click, true, falsemaskmask: mouse and keyboard reach the digital human only over its visible pixels (orbit with the right mouse button, wheel, keys while the pointer is on it); everywhere else your page keeps all input. click (since embed 1.1.0): the digital human gets the focus by a click on it and keeps all mouse and key input until the visitor clicks somewhere else, see click focus. true: the whole frame takes input. false: display only
data-autofalse–do not create the player; call Aimigo.mount(options) yourself
data-playerURLlatest playerpin a specific player version
data-sales-sheetsheet keyAvataris sheetyour Google Sheet for personal links
data-affiliate-paramquery parameter nameaimigoAffiliatewhere the personal link id is read from
data-affiliatelink id–a fixed contact id instead of the page address
data-greetingfalse–no spoken greeting for personal links (your page greets itself)
data-device-checkoff–start the player on every device, also where the device check would refuse it (very little memory), see devices and crashes
data-ios-autostarttrue–let the digital human start by itself on iPhone and iPad too (default: the visitor starts it there), see devices and crashes
data-min-memoryGB4 on Android, 2 elsewheresmallest device memory (navigator.deviceMemory) that may start; 0 = no limit
data-crash-pause-daysdays7how long automatic starts are held back after a page died while loading; 0 switches the crash guard off
data-progressfalse–hide the small loading card at the bottom right (your page shows its own, see loading or downloading)

Creating the player from code

const dh = Aimigo.mount({
  character: 'Ben',
  mode: 'transparent',          // or 'room' with scene: '<sceneId>'
  target: '#stage',             // optional container; without it: floating corner (position, width, height)
  interactive: 'mask',          // default; 'click' = focus by click, true = whole frame, false = display only
  salesSheet: 'p-yourkey',      // optional, personal links
  greeting: true
});

Use data-auto="false" on the script tag if you mount yourself. Several instances on one page are possible (Aimigo.instances()); each runs its own 3D engine and needs its own memory, so use one per page unless you really need more.

Functions of an instance

FunctionReturnsMeaning
dh.readyPromiseresolves when the character is on stage and commands are accepted; rejects with the player's error
dh.speak({ audioUrl, wordTimestamps?, text?, triggerCodes? })Promiseplays audio with lip sync. audioUrl: any format the browser decodes (MP3, WAV; OGG not in Safari), same origin or CORS-readable
dh.speak({ wavBase64, wordTimestamps? })Promisesame with ready 16-bit PCM WAV data (base64)
dh.stop()PromisePlanned: stops speaking. The current engine has no stop command yet; the call resolves with null and the audio plays to the end
dh.setCharacter(nameOrId)Promiseswitches the character; the outcome arrives as event character
dh.setMode('transparent')Promisetransparent stage; outcome as event transparency
dh.setMode('room', sceneId)Promise3D room
dh.call(command, input, timeoutMs?)Promise of the result dataany MCP command the role User may use (default timeout 30 s)
dh.on(type, fn)function that removes the listenertype: ready, event, error, contact, progress, effect, startable (two loading states)
dh.loading, dh.effect, dh.startableobject, object, booleanthe loading state of the digital human, of the enhanced image, and whether a visitor may start now
dh.visitorobject or nullsince embed 1.10.0 (Aimigo.features.includes('visitor-options')): what the owner lets visitors do, from the published settings: { rooms: { allowed, ids }, transparency, camera: { screenViews, orbit, walk, fly } }. null until the event config arrived. Use it to offer a room switch (dh.setMode('room') / dh.setMode('transparent')) only where rooms.allowed is true, and to explain only the camera controls that are on. Also part of aimigo.loading.getState and of the event config
dh.contactPromisethe contact of a personal link, or null (personal links)
dh.updateContact({ … })Promisestores what the AI learned about the contact
dh.setInteractive(mode)the mode now in effect'mask', 'click', true or false at runtime, e.g. false while your own dialog is open. Changing the mode releases a click focus
dh.inputFocused, dh.blur()boolean, –inputFocused is true while the digital human has the click focus (mode click); blur() releases it. Aimigo.features lists 'click-focus' when the loaded embed supports the mode
dh.setLayout(name), dh.layoutthe layout now in effect'auto', 'overlay', 'window', 'fullscreen', 'corner' (layouts)
dh.show(), dh.hide()–shows or hides the frame (the player keeps running)
dh.destroy()–removes the frame; pending calls reject
dh.elementelementthe container element (for your own styling)

window.Aimigo itself has mount(options), instances(), default (the instance of the script tag), audioUrlToWavBase64(url), cacheState(options) (below), version and features (a list of flags such as 'click-focus' and 'cache-state'; check a flag before you rely on a function that older embeds do not have).

Cache state

Aimigo.cacheState(options) (embed 1.2.0 and later; Aimigo.features.includes('cache-state')) answers one question before you mount anything: are the player files already in this browser's storage? Use it to start the digital human at once when almost nothing has to be downloaded, and to wait for a click, a fast connection or a better moment when the full download is ahead (performance).

const state = await Aimigo.cacheState();
if (state.cached)       Aimigo.mount({ character: 'Ben' });   // files are here: ready in seconds
else if (state.unknown) { /* no answer: decide as you would without the check */ }
else                    { /* a full download is ahead: ask first, or wait */ }

It resolves to { cached, mode, bytes, version, engine, bundles, bundleBytes, loadSource, ms }, or to { cached: false, unknown: true, reason, ms }. It never rejects.

FieldMeaning
cachedtrue: the three engine files and a good share of the content bundles of the player's current version are stored, so mounting downloads (almost) nothing. After a player update the old files do not count
modehow the player opens the storage: shared (one download for all sites, Chrome and Edge), off (your data-shared-cache="false", or "consent" without consent), opted-out (the visitor switched the shared cache off), partitioned (the browser refused), unsupported, no-handle, top-level. Everything except shared means the answer comes from this site's own storage, which is also where the player would look
loadSourcewhat mounting would do, the same value the player reports while it loads: cache, partial or network (see loading or downloading)
device{ ok, reason, platform, memory }: can this device run the digital human at all? reason is low-memory when ok is false; platform is ios, android or other and never a reason by itself (see devices and crashes)
enginetrue when the engine files (data, framework, wasm) are stored
bundles, bundleBytesnumber and size of the stored content bundles (characters, rooms, fonts)
byteseverything stored for this version, as the 3D engine counts it (uncompressed, not the transfer size)
versionplayer version the answer is about
mshow long the check took
unknown, reasonthe check could not tell: timeout (no answer in time, for example on a slow connection, or the player folder has no probe page because you pinned an old version with data-player), error: …, storage-unavailable, manifest-<status>, bad-player-url. unknown is not "not cached": decide as you would without the check

Options (all optional):

OptionDefaultMeaning
playerthe player of this embedplayer URL to ask about, for example the pinned version you also pass to Aimigo.mount
timeoutMs2000give up after this long (500 to 15000). The check loads one small page and the player manifest first; on a slow line, or while a player is already running on the same page, pass 6000
sharedCachedata-shared-cache of the script tagfalse or 'consent' as for the player: without consent the check never asks the browser for the shared storage
channelaimigoname of the message channel, only for a page that runs its own player frame with its own channel name

What it does and what it does not do:

  • It only reads. A hidden one-pixel frame loads a small page from the player host, which opens the storage the same way the player does and looks at what the 3D engine has stored there. Requests: that page, a small script and aimigo-build.json. No player file is downloaded, no 3D engine is started, nothing is written or created, even in a browser that has never seen the player.
  • No personal data and no identifier are used or created. The answer goes to your page only (checked by origin, frame and a one-time id), never to other frames or sites.
  • It tells your page whether this browser holds the player files, which is also visible from how fast the player starts. A visitor who switched the shared cache off (performance) is answered from the per-site storage, and with data-shared-cache="false" or without consent the shared storage is not even asked.
  • Call it once per page view and keep the answer; every call creates a frame.

Loading or downloading

Loading the digital human from the browser storage is not a download, and the page should not look like one. Since embed 1.3.0 (Aimigo.features.includes('load-source')), before the 3D engine starts, the player checks what the browser storage already holds and reports it as loadSource in its started and progress messages (the same check as Aimigo.cacheState()):

loadSourceMeaningBuilt-in card
cacheeverything is stored: files are only loaded from the browser storage, nothing is downloadedturning loading symbol, "Loading from browser storage" / "Wird aus dem Browser-Speicher geladen", no MB figure
partialengine stored, the character or rooms are downloadeddownload symbol, "Downloading (partly stored)" / "Wird teilweise heruntergeladen"
networknothing stored: the full download (about 220 MB, once; kept for the next visits and shared between sites in Chrome and Edge)download symbol, "Downloading" / "Wird heruntergeladen", MB figure
nullnot known (older player, check failed)neutral "Loading the digital human"

The card has a tooltip that says the same in a sentence, in the page language (German or English). cache turns into partial if more than 8 MB come over the network after all. The 3D engine's own loading figures count bytes it served from its storage as "downloaded"; for that reason the card shows megabytes only for network.

For a page with its own loading display (data-progress="false"): dh.loading.loadSource and dh.loading.networkBytes (bytes really received from the network so far), the event aimigo:progress (e.detail.loadSource) and dh.on('event') with name: 'started' (data.loadSource) carry the same values. Show the loading symbol for cache and the download symbol otherwise. Only the 3D engine's own files count as network bytes, nothing else.

You do not need your own detection: the player decides, once, for every page and platform. The player version that sends loadSource also keeps the cache across updates of the player (performance): an update of the digital human does not make visitors download everything again, only what changed.

Two loading states: the digital human and the enhanced image

Since embed 1.9.0 (Aimigo.features.includes('effect-state')) your page can follow two things that load one after the other and decide itself when to show or start the digital human.

1. The digital human: dh.loading, event progress (dh.on('progress', fn) or window event aimigo:progress).

FieldMeaning
phaseengine (3D engine), content (character and room), ready, error; paused on a held start
progress0 to 1 over both phases, null while the size is unknown
loadSource, networkBytessee Loading or downloading

2. The enhanced image ("effect", only for a digital human whose owner switched on enhanced image quality): dh.effect, event effect (dh.on('effect', fn) or window event aimigo:effect; also dh.on('event') with name: 'effect').

dh.effect.stateMeaning
offnot switched on for this digital human, or the visitor is not on a Windows desktop
checkingthe visitor's graphics card and the companion are being asked (at most about 3 seconds)
unavailablenot on this PC or not in this page view; reason says why. Nothing more will happen
no-companiona fitting graphics card, but no companion answered. retryInMs is set while it is looked for again
loadingthe companion answered and starts the enhanced image: progress 0 to 1 (from the companion's own estimate), etaMs
readythe enhanced image is on the digital human
lostit was ready and is gone; it is brought back unless the owner switched that off
skippedthe owner's upper limit passed and the setting says: not again in this visit

Other fields: available (true once a companion answered, false when this PC cannot show it, null while unknown), settled, holding, and the owner's settings start (immediate or wait), ceilingMs, afterCeiling (join or skip).

3. May the visitor start? dh.startable, event startable (dh.on('startable', fn) or window event aimigo:startable). It is true once the digital human is loaded and the enhanced image no longer stands in the way (dh.effect.settled): at once with the owner's setting "At once", after the enhanced image is ready or the upper limit has passed with "Wait for the enhanced image first".

The digital human works before the enhanced image is there; the picture then changes when it arrives. What you do with that is your choice:

const dh = Aimigo.mount({ dh: 'dh_...', progress: false });
dh.on('progress', (l) => showBar('Digital human', l.progress));              // first run
dh.on('effect', (e) => {                                                      // second run, only where it can work
  if (e.state === 'loading') showBar('Enhanced image', e.progress);
  if (e.state === 'ready') hideBar();
});
dh.on('startable', ({ startable }) => { startButton.disabled = !startable; }); // startable from "digital human loaded"

// or wait for the enhanced image yourself, whatever the owner's setting says:
const ready = () => dh.startable && (dh.effect.available === false || dh.effect.state === 'ready' || dh.effect.state === 'off' || dh.effect.state === 'skipped');

The same as one query, also for an AI that drives the page through MCP commands: dh.call('aimigo.loading.getState') answers { loading, effect, startable, visible }. It is answered by the embed itself and works while the digital human still loads.

Devices and crashes

Nobody is refused because of the brand of the device: iPhone and iPad are supported like every other device. Three protections, built once for every page (embed 1.5.0; Aimigo.features lists 'device-check', 'crash-guard' and 'held-start').

Device check. Before anything is downloaded, the player checks what can really be measured: navigator.deviceMemory where the browser tells (Chrome and Edge; Safari does not), below 4 GB on Android or 2 GB elsewhere. Nothing else is tested (no graphics probe, no brand of device). A refused start downloads nothing: dh.ready rejects with an Error that has code === 'unsupported-device' and reason (low-memory), the built-in notice says so, and the visitor can still choose "Try anyway". await Aimigo.cacheState() returns the same verdict as device before you mount. data-device-check="off" switches the check off, data-min-memory="<GB>" moves the limit.

Automatic starts are held back, not refused. An automatic start (the script tag, Aimigo.mount({ auto: true, … })) does not run

dh.pauseReasonwhenbuilt-in display
ioson iPhone and iPad (Safari ends a tab that uses too much memory; the visitor decides)a small button "Start the digital human"
crashafter a page view that died while the digital human was loading (see below), for data-crash-pause-days (default 7)a notice: "The digital human could not be loaded on this device, probably because of too little memory. The page keeps working." with the buttons "Try again" and "Turn the digital human off"
disabledwhile the visitor has switched the digital human offa small button "Turn the digital human on"

The held instance is inert: dh.paused === true, dh.ready rejects with code === 'paused', and the window event aimigo:paused carries { reason, platform, crashGuard }. A start the visitor asks for always runs: Aimigo.mount without auto (for example from your own button), the built-in buttons, or dh.retry(), which starts the held (or failed) instance and returns the live one (Aimigo.default follows it). data-ios-autostart="true" lets iPhone and iPad start by themselves too.

Crash guard. Some devices end the page while the 3D engine loads, and a reload then does the same again. The embed writes a start stamp to the page's own storage before the player loads and removes it when the digital human is ready, when an error is reported, on dh.destroy() and when the page is left. A stamp that is still there at the next page view, without a loader that is still alive (checked with a Web Lock, so another tab that is still loading is not mistaken for a crash), means the page died while loading. A start that reaches ready forgets earlier crashes. A failed load (error) shows the same notice with "Try again" (after a device refusal: "Try anyway") and "Turn the digital human off".

Turning it off. "Turn the digital human off" is remembered in the page's storage and can be undone: the pill "Turn the digital human on", or Aimigo.enable().

Your own interface. With data-progress="false" the embed shows none of these buttons and notices; your page reads the states and draws its own:

APIMeaning
dh.paused, dh.pauseReasonthe automatic start was held back, and why
dh.loading.phase === 'error', dh.loading.errorCode, .errorReasona start that failed (unsupported-device + low-memory, or another error)
dh.retry()the visitor wants another try; returns the live instance
Aimigo.disable(), Aimigo.enable(), Aimigo.disabled()the visitor's choice (remembered); event aimigo:disabled with { disabled }; disable() also removes running instances
await Aimigo.crashGuard(){ crashed, count, lastAt, pausedUntil, paused, disabled }
Aimigo.clearCrashGuard()forget the crash records
Aimigo.platform()'ios', 'android' or 'other'
const dh = Aimigo.mount({ auto: true, progress: false /* your own interface */ });
if (dh.paused) showStartButton(dh.pauseReason, () => dh.retry());   // 'ios' | 'crash' | 'disabled'

Word timestamps

Optional, improve lip sync and subtitles. One entry per spoken word, times in seconds from the start of the audio:

[ { "word": "Hello", "startTime": 0.00, "endTime": 0.42 },
  { "word": "and",   "startTime": 0.42, "endTime": 0.55 },
  { "word": "welcome", "startTime": 0.55, "endTime": 1.10 } ]

ElevenLabs returns character alignments that convert directly into this list.

Events

dh.on('event', e => console.log(e.name, e.data));
e.nameWhene.data
charactera character change finishedsuccess, characterId, errorCode?, error?
transparencya mode change finishedsuccess, enabled, errorCode?, error?
settingsa setting changed (volume, mute, language, microphone, …)name, value
contacta personal-link contact was loaded or not foundsuccess
inputFocusthe digital human got or lost the click focus (mode click)focused, reason (click on the character, click next to the character, Escape, hidden, blur(), mode changed)
greetingthe greeting of a personal link was spokensuccess, text, error?

Commands such as setCharacter answer at once with { operation: 'started', status: 'loading', completionEvent: 'character' }; the event tells you when the change is really done or why it failed.

Errors

A rejected promise carries an Error whose message comes from the player. Typical codes (in error or errorCode of results and events):

CodeMeaningWhat to do
CharacterNotFoundno character with that name or iddh.call('aimigo.character.list', {}) shows the valid ids
TransparentSceneMissingthis player version has no transparent stageuse data-mode="room" or another player version
PermissionDeniedthe command is not released for userssee permissions
InvalidInputa required parameter is missing or wrongcompare with the command reference
NotSupportedthe function does not exist on this platform–
… timed outno answer within the timeoutcheck that dh.ready resolved; pass a longer timeout

Layouts

LayoutWhat you see
auto (default)overlay while the stage is transparent, window in a 3D room; switches by itself when the mode changes
overlaythe transparent stage covers the whole browser window; your page stays fully usable next to the character
windowa 16:9 window, about a quarter of the page, bottom right. Drag the bar on top to move it, any edge or corner to resize it (any aspect ratio). ⛶ or a double-click on the bar switches to fullscreen. Size and position are remembered in the browser
fullscreenthe player fills the browser window; ❒ or Esc goes back to window
cornera fixed box in a corner (data-position, data-width, data-height)

With data-target the player fills your container and no layout applies.

Mouse and keyboard

With the default data-interactive="mask" the digital human behaves like a window on your page that is exactly as large as its silhouette:

  • Mouse: over the character's visible pixels the player receives the pointer — right mouse button held + move orbits the camera, the wheel zooms while the right button is held, clicks reach the character. Next to the character (transparent area) the page underneath receives everything as usual. A drag that starts on the character stays with it until the button is released.
  • Keyboard: while the pointer is over the character, keyboard focus moves to the player, so its keys work (for example navigation keys). When the pointer leaves, focus returns to the element that had it before. If a text field on your page has focus, it keeps it — typing in your forms is never redirected.
  • Touch screens: without a hovering pointer the frame is not switched, so in mask mode taps go to your page. To let visitors on phones touch the character, use data-interactive="true" (the frame then takes all input inside its rectangle).

Click focus

data-interactive="click" (embed 1.1.0 and later; check Aimigo.features.includes('click-focus'), older embeds treat the value like mask) is for pages where the digital human is not the main content and the visitor should decide when to talk to it with mouse and keyboard:

  • Unfocused: the player takes no input at all, not even over the character. Hovering does nothing, your page keeps every click and key.
  • Focus by a click on the character's visible pixels. The click only focuses (the page below does not receive it). From then on the player holds the pointer over the whole window, including the transparent areas: orbit with the right mouse button, wheel, middle button, drag, and all keys reach the 3D engine, wherever the pointer is. Keyboard focus moves to the player; a text field that had focus is left first.
  • Focus is lost by a click with the primary mouse button on a transparent area (the click is then handed on to the page element under the pointer, as if the character were not there), by Escape, by dh.hide(), dh.blur() or dh.setInteractive(...). Right and middle button presses beside the character do not leave the focus, so an orbit drag can start anywhere.
  • Your own controls in front of the layer win. If an element of your page is stacked above the player layer (a control bar, a toast, a footer), a click on it never focuses the digital human, even where the character's pixels are behind it; a click on such an element while the digital human is focused leaves the focus and reaches your element as usual.
  • Listen to dh.on('event', e => e.name === 'inputFocus' && console.log(e.data)) to show the state in your own UI, or read dh.inputFocused.
  • Fading without focus (embed 1.11.0 and later, Aimigo.features.includes('click-dim')): with the owner's setting "Fade when it is not in focus" the transparent digital human is shown at the chosen visibility after the visitor clicked your page or left the click focus, and fully visible again while it has the focus. Before 1.11.0 the setting only worked in mask mode.
  • Inside the Aimigo preview (embed 1.11.0): when your page is shown in the settings preview at aimigo.live, the embed on your page starts nothing (dh.paused, dh.pauseReason === 'studio'); the preview draws the digital human itself, with the settings being edited.

This page as Markdown · llms.txt · All docs in one file