Listen to Events

React to conversation and avatar activity in your app.

Basic pattern

import { Experience } from '@liforma/client';

const experience = await Experience.startSession({
  experienceId: 'exp_…'
});

experience.on('message', ({ role, text, final }) => {
  if (role === 'assistant' && final) {
    appendToChatLog(text);
  }
});

experience.on('modeChange', ({ mode }) => {
  setMicIndicator(mode === 'listening');
});

experience.on('close', ({ reason }) => {
  navigateAway(reason);
});

await experience.attach({ container: '#avatar' });

Common use cases

GoalEvent
Show transcriptmessage
Mic/speaker indicatormodeChange
Sync UI with world statestateUpdate
Handle user closing avatarclose