AI Dialog
Updated
The visible conversation interface of the agent.
- Type
ent-ai-dialog- Script class
AIDialogEntity- Family
- Logic and AI
Overview
Section titled “Overview”An AI Dialog entity is a chat panel on an entity of its own: a UI panel that shows the conversation of an AI Agent placed elsewhere in the scene, with the agent’s name, the latest exchange and a field to type or speak into. It holds no model and no conversation: it only presents those of the agent it points to.
Where it comes from. The AI Dialog entity is kept so that scenes saved with it still load and work. The Add menu does not offer it any more: a dialog is now an AI Dialog component added to the agent itself, which always presents that agent. You meet this entity when you open an older scene, and scripts can still find it, show and hide it, and change its settings.
What it is made of. The entity is a UI panel: a required UI Layout (in overlay render mode, arranging its content in a column) and a required UI Panel (its background box, with an opacity), plus the AI Dialog component that does the work. Because it is a panel, it also accepts the components panels take, such as a Billboard, a Follow Target or a Grabbable.
Editor and play. In the editor it is an inert preview: it shows the agent’s name and opens no conversation and no microphone. In play it binds to its agent’s conversation.
When to use it. For new work, add an AI Dialog component to the agent instead, and keep the standalone entity only in scenes that already have one. The last example on this page moves a standalone dialog’s settings onto its agent.
The props that matter most, on its AI Dialog component:
sourceandagentIdtell the panel which agent to present. Withsourceset to'agent', the default,agentIdholds the id of that AI Agent entity. These two props, andprompt, apply only to the standalone entity; on an agent, the dialog always presents its own agent.presentationis'always'(shown whenever it is enabled) or'proximity'(shown while the player’s camera is inside the agent’s AI Proximity box).microphoneoffers voice input in the composer, andautoSpeakspeaks each finished reply through the agent’s AI Text To Speech.subtitleis a line shown under the agent’s name. It is never sent to the model.
Set it up
Section titled “Set it up”- Open the scene that holds the AI Dialog entity, and find it in the Hierarchy (see Scenes and hierarchy). Give it a clear name, such as
Guide Dialog. - Check that its AI Dialog component points to an AI Agent that is still in the scene, and that this agent has an AI Model.
- Set
presentation,microphone,autoSpeakandsubtitleas you would on an agent’s own dialog. - Enter play and type a message: the agent’s reply appears in the panel.
- When you rework the scene, consider moving the dialog onto the agent, as in the last example below.
Examples
Section titled “Examples”Show the dialog with a key
Section titled “Show the dialog with a key”Hide the standalone dialog at startup and toggle it with the H key.
#pragma lifecycle(startup, update)
// Scene: an AI Dialog entity named "Guide Dialog".let panel;
function startup() { panel = findEntity('Guide Dialog'); if (!(panel instanceof AIDialogEntity)) return log('No standalone dialog named Guide Dialog.'); panel.setEnabled(false);}
function update() { if (!panel) return; if (Input.keyboard.isKeyReleased(Key.H)) panel.setEnabled(!panel.isEnabled());}How it works
instanceof AIDialogEntitychecks that the entity found by name really is a standalone dialog.setEnabled(false)switches off the whole entity, panel and dialog together. Disabling the dialog also stops any voice input, which never restarts by itself.isKeyReleasedis true for the one frame the key comes up, so one press toggles once.
Check the dialog’s setup
Section titled “Check the dialog’s setup”Log what keeps the dialog from working, and give it a subtitle.
#pragma lifecycle(startup)
// Scene: an AI Dialog entity named "Guide Dialog".function startup() { const dialog = findEntity('Guide Dialog').getComponent(AIDialogComponent); const agent = findEntity(dialog.props.agentId); log('Presents:', agent ? AIPersonaComponent.displayName(agent) : 'no agent found');
dialog.setProps({ subtitle: 'Ask me about the collection', microphone: false });
const issue = dialog.getConfigurationIssue(); if (issue) log('Dialog problem:', issue);}How it works
dialog.props.agentIdis the id of the agent the panel presents.findEntityaccepts an id as well as a name.AIPersonaComponent.displayName(agent)is the name the panel’s header shows: the agent’s persona name, else its entity name, elseAgent.setPropschanges only the props it is given: here the subtitle, andmicrophone: false, which hides the Mic button and keeps typed chat.getConfigurationIssue()returns a sentence describing what keeps the dialog from working, such asproximitypresentation without an AI Proximity, orundefinedwhen all is well.
Move the dialog onto its agent
Section titled “Move the dialog onto its agent”Copy a standalone dialog’s settings onto its agent as an AI Dialog component, then switch the standalone entity off.
#pragma lifecycle(startup)
// Scene: an AI Dialog entity named "Guide Dialog" that presents an AI Agent.function startup() { const panel = findEntity('Guide Dialog'); const old = panel.getComponent(AIDialogComponent); const agent = findEntity(old.props.agentId); if (!(agent instanceof AIAgentEntity)) return log('The dialog presents no agent in this scene.'); if (agent.getComponent(AIDialogComponent)) return log('The agent already has a dialog.');
const p = old.props; agent.addComponent(new AIDialogComponent({ presentation: p.presentation, subtitle: p.subtitle, microphone: p.microphone, autoSpeak: p.autoSpeak, positioning: 'world', panelOffset: { x: 0, y: 1.8, z: 0 }, billboard: true, }));
panel.setEnabled(false); log('The dialog now lives on', agent.name);}How it works
- The script reads the old dialog’s props and builds a new
AIDialogComponentwith them;addComponentattaches it to the agent, which then presents itself. source,agentIdandpromptare left out: on an agent they do not apply.positioning: 'world'places the panel at the agent’s position pluspanelOffset, in metres, andbillboard: trueturns it to face the camera.- The standalone entity is switched off rather than destroyed, so nothing is lost if you need to compare. This runs each time the scene plays; to make the change permanent, add the component to the agent in the editor and delete the old entity.
- A panel that presents no agent, because the agent was deleted or its id changed, shows nothing useful.
getConfigurationIssue()and theagentIdcheck above find it quickly. - In a headset, prefer
worldpositioning: ascreenpanel follows the head.
Components
Section titled “Components”What a new AI Dialog is made of. Required components are always present and cannot be removed; the others can. Per entity says whether an entity can hold one of that component or several. Layer, Lock and Enable are on every placed entity, and Transform holds its position, rotation and scale.
| Component | Type | Role | Per entity | What it does |
|---|---|---|---|---|
| Layer | comp-layer |
Required | One | Puts the entity on a render/raycast layer so cameras and rays can include or skip it. |
| Lock | comp-lock |
Required | One | Editor-only flag that stops the entity from being selected or moved. |
| Enable | comp-enable |
Required | One | Turns the entity and its children on or off: hides them and stops their behavior. |
| Transform | comp- |
Required | One | Position, rotation and scale of the entity, with optional editor-only per-axis locks. |
| UI Layout | comp- |
Required | One | Flexbox container that arranges child UI elements. |
| UI Panel | comp-ui-panel |
Required | One | Background box of an element: fill, rounded corners, border. |
| AI Dialog | comp- |
Starts with | One | The visible conversation interface of the agent. |
You can also add 19 optional components, such as Animation Graph, Animation Timeline, Billboard, Dont Unload, Enable On Signal, Follow Target.
The settings of a new entity, as the runtime creates it. Change them in the Properties panel of XR Creator, or from a script with getComponent(…).setProps({ … }).
UI Layout
Section titled “UI Layout”| Prop | Default | Range |
|---|---|---|
renderMode |
"overlay" |
|
alignItems |
"stretch" |
|
justify |
"flex-start" |
|
flexDirection |
"column" |
UI Panel
Section titled “UI Panel”| Prop | Default | Range |
|---|---|---|
opacity |
1 |
0 ≤ x ≤ 1 |
AI Dialog
Section titled “AI Dialog”| Prop | Default | Range |
|---|---|---|
autoSpeak |
false |
|
microphone |
true |
|
source |
"agent" |
|
agentId |
"" |
|
subtitle |
"" |
|
prompt |
"" |
|
presentation |
"always" |
|
panelOffset |
{"x":0,"y":0,"z":0} |
|
panel |
{"x":0,"y":0,"z":0} |
|
positioning |
"world" |
|
billboard |
false |
|
screenAnchor |
"center" |
|
insetX |
0 |
- |
insetY |
0 |
- |
screenScale |
0.7 |
0.1 ≤ x ≤ 1 |
panelWidth |
420 |
320 ≤ x ≤ 960 |
pixelSize |
0.003 |
0.001 ≤ x ≤ 1 |
Events
Section titled “Events”With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.
It reports the events every entity has: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
A standalone AI Dialog entity above a desk presents the conversation of a guide standing elsewhere in the room: its dialog names the agent by id.
The panel over the desk is Ada's conversation, though Ada stands across the room. Type a message to try it. Replies need the AI service, which this preview does not have: a message you send shows a short error in the panel instead. Drag outside the panel to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”Find the entity by its name, check its class, and work with its components. Name the entity in the Hierarchy first; this example expects My AI Dialog.
#pragma lifecycle(startup)
function startup() { // Find the entity by the name it has in the Hierarchy. const entity = findEntity('My AI Dialog'); if (!(entity instanceof AIDialogEntity)) return;
// Its UI Layout component holds the settings listed under Props. const component = entity.getComponent(UILayoutComponent); log(component.props);}