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.
| Attribute | Values | Default | Meaning |
|---|---|---|---|
data-character | character name, id or slot | Ben | character loaded at start |
data-mode | transparent, room | transparent | transparent stage over your page, or a 3D room |
data-scene | scene id | default room | 3D room for data-mode="room" |
data-layout | auto, overlay, window, fullscreen, corner | auto | how the player sits on the page, see layouts |
data-position | bottom-right, bottom-left, top-right, top-left | bottom-right | corner of the frame in layout corner |
data-width, data-height | CSS sizes | min(34vw,420px), min(62vh,620px) | size of the frame in layout corner (setting one of them selects corner) |
data-target | CSS selector | – | put the player into this element (it fills it) instead of a floating corner |
data-interactive | mask, click, true, false | mask | mask: 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-auto | false | – | do not create the player; call Aimigo.mount(options) yourself |
data-player | URL | latest player | pin a specific player version |
data-sales-sheet | sheet key | Avataris sheet | your Google Sheet for personal links |
data-affiliate-param | query parameter name | aimigoAffiliate | where the personal link id is read from |
data-affiliate | link id | – | a fixed contact id instead of the page address |
data-greeting | false | – | no spoken greeting for personal links (your page greets itself) |
data-device-check | off | – | start the player on every device, also where the device check would refuse it (very little memory), see devices and crashes |
data-ios-autostart | true | – | let the digital human start by itself on iPhone and iPad too (default: the visitor starts it there), see devices and crashes |
data-min-memory | GB | 4 on Android, 2 elsewhere | smallest device memory (navigator.deviceMemory) that may start; 0 = no limit |
data-crash-pause-days | days | 7 | how long automatic starts are held back after a page died while loading; 0 switches the crash guard off |
data-progress | false | – | 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
| Function | Returns | Meaning |
|---|---|---|
dh.ready | Promise | resolves when the character is on stage and commands are accepted; rejects with the player's error |
dh.speak({ audioUrl, wordTimestamps?, text?, triggerCodes? }) | Promise | plays 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? }) | Promise | same with ready 16-bit PCM WAV data (base64) |
dh.stop() | Promise | Planned: 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) | Promise | switches the character; the outcome arrives as event character |
dh.setMode('transparent') | Promise | transparent stage; outcome as event transparency |
dh.setMode('room', sceneId) | Promise | 3D room |
dh.call(command, input, timeoutMs?) | Promise of the result data | any MCP command the role User may use (default timeout 30 s) |
dh.on(type, fn) | function that removes the listener | type: ready, event, error, contact, progress, effect, startable (two loading states) |
dh.loading, dh.effect, dh.startable | object, object, boolean | the loading state of the digital human, of the enhanced image, and whether a visitor may start now |
dh.visitor | object or null | since 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.contact | Promise | the contact of a personal link, or null (personal links) |
dh.updateContact({ … }) | Promise | stores 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.layout | the 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.element | element | the 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.
| Field | Meaning |
|---|---|
cached | true: 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 |
mode | how 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 |
loadSource | what 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) |
engine | true when the engine files (data, framework, wasm) are stored |
bundles, bundleBytes | number and size of the stored content bundles (characters, rooms, fonts) |
bytes | everything stored for this version, as the 3D engine counts it (uncompressed, not the transfer size) |
version | player version the answer is about |
ms | how long the check took |
unknown, reason | the 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):
| Option | Default | Meaning |
|---|---|---|
player | the player of this embed | player URL to ask about, for example the pinned version you also pass to Aimigo.mount |
timeoutMs | 2000 | give 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 |
sharedCache | data-shared-cache of the script tag | false or 'consent' as for the player: without consent the check never asks the browser for the shared storage |
channel | aimigo | name 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()):
loadSource | Meaning | Built-in card |
|---|---|---|
cache | everything is stored: files are only loaded from the browser storage, nothing is downloaded | turning loading symbol, "Loading from browser storage" / "Wird aus dem Browser-Speicher geladen", no MB figure |
partial | engine stored, the character or rooms are downloaded | download symbol, "Downloading (partly stored)" / "Wird teilweise heruntergeladen" |
network | nothing 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 |
null | not 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).
| Field | Meaning |
|---|---|
phase | engine (3D engine), content (character and room), ready, error; paused on a held start |
progress | 0 to 1 over both phases, null while the size is unknown |
loadSource, networkBytes | see 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.state | Meaning |
|---|---|
off | not switched on for this digital human, or the visitor is not on a Windows desktop |
checking | the visitor's graphics card and the companion are being asked (at most about 3 seconds) |
unavailable | not on this PC or not in this page view; reason says why. Nothing more will happen |
no-companion | a fitting graphics card, but no companion answered. retryInMs is set while it is looked for again |
loading | the companion answered and starts the enhanced image: progress 0 to 1 (from the companion's own estimate), etaMs |
ready | the enhanced image is on the digital human |
lost | it was ready and is gone; it is brought back unless the owner switched that off |
skipped | the 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.pauseReason | when | built-in display |
|---|---|---|
ios | on iPhone and iPad (Safari ends a tab that uses too much memory; the visitor decides) | a small button "Start the digital human" |
crash | after 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" |
disabled | while the visitor has switched the digital human off | a 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:
| API | Meaning |
|---|---|
dh.paused, dh.pauseReason | the automatic start was held back, and why |
dh.loading.phase === 'error', dh.loading.errorCode, .errorReason | a 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.name | When | e.data |
|---|---|---|
character | a character change finished | success, characterId, errorCode?, error? |
transparency | a mode change finished | success, enabled, errorCode?, error? |
settings | a setting changed (volume, mute, language, microphone, …) | name, value |
contact | a personal-link contact was loaded or not found | success |
inputFocus | the 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) |
greeting | the greeting of a personal link was spoken | success, 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):
| Code | Meaning | What to do |
|---|---|---|
CharacterNotFound | no character with that name or id | dh.call('aimigo.character.list', {}) shows the valid ids |
TransparentSceneMissing | this player version has no transparent stage | use data-mode="room" or another player version |
PermissionDenied | the command is not released for users | see permissions |
InvalidInput | a required parameter is missing or wrong | compare with the command reference |
NotSupported | the function does not exist on this platform | – |
… timed out | no answer within the timeout | check that dh.ready resolved; pass a longer timeout |
Layouts
| Layout | What you see |
|---|---|
auto (default) | overlay while the stage is transparent, window in a 3D room; switches by itself when the mode changes |
overlay | the transparent stage covers the whole browser window; your page stays fully usable next to the character |
window | a 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 |
fullscreen | the player fills the browser window; ❒ or Esc goes back to window |
corner | a 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
maskmode taps go to your page. To let visitors on phones touch the character, usedata-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, bydh.hide(),dh.blur()ordh.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 readdh.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 inmaskmode. - 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.