Skip to content

Dialog and captions

Updated

An agent needs a face on screen. The AI Dialog is its chat panel: the agent’s name, the latest exchange, and a field to type or speak into. The AI Caption shows subtitles of the speech the agent hears and says. The AI Proximity is an invisible box around the agent that notices when the player walks in or out, so the panel can open on approach and the agent can greet them. All three are presentation: they read the agent’s shared conversation and never change what the model answers.

  • You have an agent with an AI Model, and ideally an AI Persona. See Creating an agent.
  • The panels are UI. Screen and world placement work as for any panel; see UI.
  • Scripts react to the panels through the agent’s Signal Emitter. See Scripting AI.

The AI Dialog (comp-ai-dialog, AIDialogComponent) goes on the agent. From top to bottom the panel holds:

  • Header. An avatar tile, the agent’s display name (its Persona’s name, else the entity’s name, else Agent), and the optional subtitle.
  • Language button. Shown when the agent has an enabled AI Translation. It opens a menu to switch translation on and pick a language. See Translation and memory.
  • Messages. The latest visitor message and the agent’s reply, each scrolling when it is long. While a new turn runs, the panel shows progress. An empty panel says “Hi! How can I help?”.
  • Play button. Next to a finished reply when the agent has an enabled AI Text To Speech: it speaks the reply, and turns into Stop while it plays.
  • Composer. A text field that grows to three lines. Empty, it offers Mic (when microphone is on). With text, it offers Send. During a turn it offers Stop, which cancels the reply and keeps your next draft.

When a turn fails, the panel keeps the conversation and the draft and shows a short message. Replies are shown as readable plain text: formatting marks such as headings and list markers are turned into ordinary text.

Prop Type Default Description
presentation 'proximity' or 'always' 'always' Show the panel always, or only while the player’s camera is inside the agent’s AI Proximity box.
subtitle string '' A line under the name. Never sent to the model.
microphone boolean true Offer voice input in the composer.
autoSpeak boolean false Speak each finished reply through AI Text To Speech.
positioning 'world' or 'screen' 'world' Place the panel in the world next to the agent, or pinned to the screen.
panelOffset { x, y, z } in metres { x: 0, y: 0, z: 0 } World only: offset from the agent, in its local space.
panelOrientation { x, y, z } in radians { x: 0, y: 0, z: 0 } World only: extra rotation, applied after billboarding.
billboard boolean false World only: turn the panel to face the camera.
screenAnchor 'top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom' or 'bottom-right' 'center' Screen only: the point of the viewport the panel is pinned to.
insetX, insetY number, px 0, 0 Screen only: offset from the anchor.
screenScale number 0.7 Screen only: size on screen, 0.1 to 1.
panelWidth number, px 420 Panel width in layout pixels, 320 to 960.
pixelSize number, m per px 0.003 World only: metres per layout pixel.
backgroundColor string the theme’s dialog surface Panel fill. Accepts #RRGGBBAA, rgba(…) and transparent; alpha fades the fill only, not the text.
textColor string the theme’s text colours Text colour override. Clear it to follow the theme.
font string the project’s UI font Font family of every text in the panel, by name.

Placement. In world, the panel sits at the agent’s origin plus panelOffset, and scales with pixelSize. In screen, it is pinned to the viewport at screenAnchor plus the insets; in a headset a screen panel follows the head, so prefer world for XR. Placement never moves the agent itself.

Microphone. With microphone: true, an empty composer shows Mic. It stays visible but disabled, with a tooltip saying why, while the agent has no enabled AI Speech To Text, its sources lack 'microphone', or the application turns the microphone off. Showing the dialog never opens the microphone; hiding or disabling it stops voice input, which never resumes by itself.

Member What it does
setEnabled(on) Show or hide the panel. Enabled, it shows in always presentation or follows the Proximity box. Disabled, it hides and cancels only its own automatic work.
setProps(patch) Change any of the props above. Placement, colour and font edits update the panel in place.
getConfigurationIssue() A sentence describing what keeps the dialog from working, such as a missing Proximity in proximity presentation, or undefined.

A button can open a dialog with no script:

  1. On the agent, set the dialog’s presentation to always and save the dialog disabled.
  2. On the button, add a Signal Emitter with signal: guide/open and eventFilter: [UIButton::press].
  3. On the agent, add an Enable On Signal with signal: guide/open, action: enable and targetFilter: [AIDialog].

A press now enables the dialog in play. Use action: toggle for one open and close button.

The AI Caption (comp-ai-caption, AICaptionComponent) shows subtitles of what the agent’s AI Speech To Text recognizes: the agent’s own speech, and any other audio its sources select. Without Speech To Text it shows nothing, and typed text never becomes a caption.

  • It shows the current line only, in a two-line window. A finished line stays for 6 seconds, and a new line restarts that time.
  • Pausing, muting or cancelling speech clears it at once.
  • With translation on, finished lines are translated before they show.
  • Captions are never saved. Removing the caption leaves recognition running.
Prop Type Default Description
positioning 'world' or 'screen' 'world' Placement, as for the dialog.
panelOffset { x, y, z } in metres { x: 0, y: 0.6, z: 0 } World only: offset from the agent.
panelOrientation { x, y, z } in radians { x: 0, y: 0, z: 0 } World only: extra rotation.
billboard boolean false World only: face the camera.
screenAnchor one of the nine anchors 'bottom' Screen only.
insetX, insetY number, px 0, 22 Screen only: offset from the anchor.
screenScale number 0.7 Screen only: size on screen, 0.1 to 1.
panelWidth number, px 340 Width in layout pixels.
pixelSize number, m per px 0.002 World only: metres per layout pixel.
fontSize number, px 16 Text size.
font string the project’s UI font Font family.
color string '#ffffff' Text colour.
backgroundColor string the theme’s dialog surface Panel fill; transparency allowed.
padding number, px 22 Inner padding.
textAlign 'left', 'center' or 'right' 'center' Text alignment.

Colour, font and placement edits update the caption in place without dropping the current line.

The AI Proximity (comp-ai-proximity, AIProximityComponent) is a box around the agent that follows the active camera: the player is “inside” while the camera is in the box. It needs no collider and no character controller. Add it to the agent and set the dialog’s presentation to proximity, and the panel shows only while the player is near.

Prop Type Default Description
halfExtents { x, y, z } in metres { x: 1, y: 1, z: 1 } Half the box’s size along each axis, in the agent’s local space: the default is a 2 m cube.
enterPrompt string '' Sent to the agent as a hidden command when the player walks in. Empty sends nothing.
leavePrompt string '' Sent as a hidden command when the player walks out. Empty sends nothing.

In play, each crossing sends its non-empty prompt through the agent’s conversation as a command: the visitor does not see the prompt, but sees the agent’s reply, which is spoken like any other. The latest crossing wins: walking out cancels a greeting still being written. A turn your script started is never cancelled by a crossing.

Member What it does
getSnapshot() { inside, available }: whether the camera is in the box, and whether the box is working.
subscribe(listener) Call listener() each time the snapshot changes. Returns the function that stops it.
sendPrompt('enter' or 'exit', { signal? }) Send the configured enter or leave prompt yourself.
Event Data When
AIProximity::enter { inside } The camera entered the box.
AIProximity::exit { inside } The camera left it.

The events go to the Signal Emitters on the agent. In the editor, a selected agent draws the box as a translucent outline.

OpenGuide.jx
#pragma lifecycle(startup)
function startup() {
const dialog = findEntity('Guide').getComponent(AIDialogComponent);
log('The dialog starts', dialog.enabled ? 'open' : 'closed');
on('guide/open', (event) => {
if (event.eventType !== EventType.UIButton.Press) return;
dialog.setEnabled(!dialog.enabled);
log('The dialog is now', dialog.enabled ? 'open' : 'closed');
const issue = dialog.getConfigurationIssue();
if (issue) log('The dialog cannot work yet:', issue);
});
}
  • dialog.enabled reads the current state, so one button opens and closes the panel.
  • getConfigurationIssue() explains what is missing, for example a Proximity box in proximity presentation, which is far easier than guessing why nothing shows.
DialogPlacement.jx
#pragma lifecycle(startup)
// Scene: an AI Agent named "Guide" with an AI Dialog and an AI Caption,
// and a UI Switch "Pin to screen" with a Signal Emitter on 'settings:pin'.
function startup() {
const guide = findEntity('Guide');
const dialog = guide.getComponent(AIDialogComponent);
const caption = guide.getComponent(AICaptionComponent);
dialog.setProps({ subtitle: 'Ask me about the collection', billboard: true, panelOffset: { x: 0, y: 0.4, z: 0 } });
on('settings:pin', (event) => {
if (event.eventType !== EventType.UISwitch.Change) return;
if (event.data.checked) {
dialog.setProps({ positioning: 'screen', screenAnchor: 'bottom-right', insetX: 24, insetY: 24, screenScale: 0.8 });
caption.setProps({ positioning: 'screen', screenAnchor: 'bottom', insetY: 22 });
} else {
dialog.setProps({ positioning: 'world' });
caption.setProps({ positioning: 'world' });
}
});
}
  • The world values (billboard, panelOffset) are kept while the panel is on the screen, so switching back restores the old placement.
  • Insets are in screen pixels from the anchored corner, like a CSS margin.
GuideGreeting.jx
#pragma lifecycle(startup)
function startup() {
const guide = findEntity('Guide');
const proximity = guide.getComponent(AIProximityComponent);
const hint = findEntity('Talk Hint');
proximity.setProps({
halfExtents: { x: 3, y: 2, z: 3 },
enterPrompt: 'The visitor just walked up. Greet them in one sentence.',
leavePrompt: '',
});
hint.visible = !proximity.getSnapshot().inside;
on('guide:ai', (event) => {
if (event.eventType === EventType.AIProximity.Enter) hint.visible = false;
if (event.eventType === EventType.AIProximity.Exit) hint.visible = true;
});
}
  • The enterPrompt greeting is sent automatically on each entry. The script does not send it again: it only reacts to the crossing by hiding a hint.
  • getSnapshot() gives the state at startup, before any crossing happens.
  • AI Proximity events reach the same Signal Emitter as the agent’s own events, so one listener handles both.
CaptionStyle.jx
#pragma lifecycle(startup)
// Scene: an AI Agent named "Guide" with AI Speech To Text and an AI Caption.
function startup() {
const caption = findEntity('Guide').getComponent(AICaptionComponent);
caption.setProps({
positioning: 'screen',
screenAnchor: 'bottom',
insetY: 40,
panelWidth: 600,
fontSize: 22,
color: '#fde68a',
backgroundColor: 'rgba(15, 23, 42, 0.75)',
textAlign: 'center',
});
}
  • A wide, screen-anchored caption at the bottom reads like film subtitles.
  • backgroundColor accepts transparency, so the scene shows through behind the text.
  • proximity presentation without a Proximity box. The panel never shows. Add an AI Proximity to the same agent, or check getConfigurationIssue().
  • Sending the greeting twice. The Proximity already sends enterPrompt on entry. A script that also calls conversation.send on AIProximity::enter makes the agent greet twice, or fails because a turn is running.
  • Captions without Speech To Text. The caption shows what speech recognition hears; typed chat never becomes a caption.
  • Screen panels in XR. A screen-positioned panel follows the head in a headset. Use world with billboard: true for headsets.
  • Expecting a title prop. The header shows the Persona’s name. Change the name on the AI Persona, and use subtitle for extra text.