i
hi
t
Thanks for reaching out, Raj. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi — thanks for reaching out. How can I help today? If you’re not sure where to start, here are a few things I can assist with: • Setting up a LiveKit client or server • Troubleshooting connection, audio, or video issues • Managing rooms, participants, or permissions • SDK/API usage, code examples, or error debugging • Billing, account, or plan questions Tell me which area you need help with and any relevant details (project ID, room name, SDK/language, error messages).
i
Copy code
{
  "room": "45422f43-d42b-11f0-8669-e607ee80f591",
  "roomID": "RM_LuYbWcSWXLD7",
  "participant": "client",
  "pID": "PA_h7uGVy4CDj6N"
}
t
Thanks — I see the room
45422f43-d42b-11f0-8669-e607ee80f591
(ID
RM_LuYbWcSWXLD7
) and participant
client
(ID
PA_h7uGVy4CDj6N
). What would you like help with for this room or participant? A few examples you can reply with: • "Participant can't publish audio/video" — include SDK/language and any error logs • "Join failures" — include the SDK, client logs, and timestamp • "Remove or mute a participant" — tell me which action you want • "Inspect room state" — tell me if you want participant list, track list, or connection stats If you're not sure, tell me what you're trying to accomplish and I'll suggest next steps.
i
livekit_url string required livekit_room string required livekit_client_token string required how to get these
t
You're asking how to get
livekit_url
,
livekit_room
, and
livekit_client_token
. Here's how to obtain each and what to do next. • livekit_url ◦ For LiveKit Cloud: find your project WebSocket URL in the LiveKit Cloud Dashboard → Project Settings. It typically starts with
wss://
. ◦ For self-hosted: use your server's public WebSocket address (e.g.,
ws://localhost:7880
during development). • livekit_room ◦ Any unique string you choose. Rooms are created when the first participant joins. Use a fixed name for tests (e.g.,
test_room
) or generate one per meeting/session in your app. • livekit_client_token ◦ Generate this on your backend using your LiveKit API key and secret with a Server SDK or the CLI. The token includes identity, room, and permissions (roomJoin, canPublish, canSubscribe). ◦ Example (Node.js):
Copy code
import { AccessToken } from 'livekit-server-sdk';
    const at = new AccessToken('api-key', 'api-secret', { identity: 'user123' });
    at.addGrant({ room: 'my-room', roomJoin: true, canPublish: true, canSubscribe: true });
    const token = await at.toJwt();
• Example CLI (testing):
Copy code
lk token create --api-key <key> --api-secret <secret> --room my-room --identity user123 --join
Next step: tell me whether you're using LiveKit Cloud or a self-hosted server, and which backend language (Node, Go, Python, etc.) you want sample token-generation code for — I’ll provide a short snippet you can use. For reference: see the Generating Tokens guide: https://docs.livekit.io/home/server/generating-tokens Sources: Connecting to LiveKit | LiveKit docs | LiveKit CLI Setup | LiveKit Docs | Authentication | LiveKit docs | Generating tokens | LiveKit docs
i
im not sure im using liveavatar full mode
t
You're unsure whether "LiveAvatar full mode" applies — thanks for clarifying. To help, could you tell me one of the following: • Are you using LiveKit Agents with the LiveAvatar plugin? • Do you have any config or code (agent/plugin settings, YAML, or SDK snippet) you can paste here? • Are you using a vendor dashboard or a hosted product that mentions "full mode"? If you share which backend language or SDK you use (Node, Go, Python, or CLI), I’ll give the exact steps to get
livekit_url
, pick a
livekit_room
, and generate a
livekit_client_token
for your setup. Sources: LiveAvatar virtual avatar integration guide | LiveKit docs | Connecting to LiveKit | LiveKit docs
i
curl --request POST \ --url https://api.liveavatar.com/v1/sessions/token \ --header 'X-API-KEY: 066a7fa2e369' \ --header 'accept: application/json' \ --header 'content-type: application/json' curl --request POST \ --url https://api.liveavatar.com/v1/sessions/start \ --header 'accept: application/json' \ --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyNzY0NzAxNjY3NzI0Yjg1ODM1NzI1NDE2MmU1YTgxYiIsInNlc3Npb25faWQiOiIwOGE5NDYzZi1lM2E3LTQwYzgtOTI3Zi0zMDlkNTIyMmRkYzUiLCJzb3VyY2UiOiJBUEkiLCJzdGFydF9zZXNzaW9uX2RhdGEiOnsibW9kZSI6IkZVTEwiLCJhdmF0YXJfaWQiOiI1MTNmZDFiNy03ZWY5LTQ2NmQtOWFmMi0zNDRlNTFlZWI4MzMiLCJhdmF0YXJfcGVyc29uYSI6eyJ2b2ljZV9pZCI6IjljMGQ0NTc3LTI4NjMtNGQ5Ni1iNDc2LTA1ZGNkMjg4NzhkYSIsImNvbnRleHRfaWQiOiJiOWZiOGVjZC0yNDIwLTRkODUtYWQxNS00YmU3ZGI4OTdlOWYiLCJsYW5ndWFnZSI6ImVuIn19LCJleHAiOjE3NjUxODQ2ODN9.bw_Ur0ax-rUkMBSk6ICCUzFSczLZV6zKpPRF0r1DHg8'
t
Thanks — you’re using LiveAvatar’s API calls. I’ll walk you through the exact steps to get the three LiveKit parameters when using LiveAvatar in FULL mode. 1) Acquire a LiveAvatar session token • Call the sessions token endpoint with your API key and a request body that includes the avatar ID. • Example:
Copy code
curl -X POST https://api.liveavatar.com/v1/sessions/token \
  -H "X-API-KEY: 066a7fa2e369" \
  -H "Content-Type: application/json" \
  -d '{"data": {"avatar_id": "YOUR_AVATAR_ID"}}'
• Response: a Bearer session token (use this for the next step). 2) Start a FULL mode session • Use the Bearer token returned above and include the mode in the body. • Example:
Copy code
curl -X POST https://api.liveavatar.com/v1/sessions/start \
  -H "Authorization: Bearer <LIVEAVATAR_SESSION_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"data": {"mode": "FULL"}}'
• Response: the JSON will include LiveAvatar session details and the LiveKit connection info you need: ◦
livekit_url
— the WebSocket URL for the LiveKit server ◦
livekit_room
— the room name to join ◦ sometimes LiveAvatar may return client credentials; if it returns a LiveKit client token, you can use that directly as
livekit_client_token
. 3) If LiveAvatar does NOT return
livekit_client_token
• Generate the LiveKit client token on your backend using your LiveKit API key/secret and the returned
livekit_room
+ participant identity. • Short Node.js example:
Copy code
import { AccessToken } from 'livekit-server-sdk';
const at = new AccessToken('LIVEKIT_API_KEY', 'LIVEKIT_API_SECRET', { identity: 'user123' });
at.addGrant({ room: 'returned-room-name', roomJoin: true, canPublish: true, canSubscribe: true });
const livekit_client_token = await at.toJwt();
What I need from you to proceed: • Paste the exact JSON response you got from
/v1/sessions/start
(mask any secrets) — I’ll point out the
livekit_url
and
livekit_room
fields and tell you whether a client token was returned. • If no client token was returned, tell me which backend language you use (Node/Go/Python) and I’ll give the exact token-generation snippet you can drop into your server. Would you like me to inspect the
/sessions/start
response you received? Sources: LiveAvatar virtual avatar integration guide | LiveKit docs | Authentication | LiveKit docs
i
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyNzY0NzAxNjY3NzI0Yjg1ODM1NzI1NDE2MmU1YTgxYiIsInNlc3Npb25faWQiOiIwOGE5NDYzZi1lM2E3LTQwYzgtOTI3Zi0zMDlkNTIyMmRkYzUiLCJzb3VyY2UiOiJBUEkiLCJzdGFydF9zZXNzaW9uX2RhdGEiOnsibW9kZSI6IkZVTEwiLCJhdmF0YXJfaWQiOiI1MTNmZDFiNy03ZWY5LTQ2NmQtOWFmMi0zNDRlNTFlZWI4MzMiLCJhdmF0YXJfcGVyc29uYSI6eyJ2b2ljZV9pZCI6IjljMGQ0NTc3LTI4NjMtNGQ5Ni1iNDc2LTA1ZGNkMjg4NzhkYSIsImNvbnRleHRfaWQiOiJiOWZiOGVjZC0yNDIwLTRkODUtYWQxNS00YmU3ZGI4OTdlOWYiLCJsYW5ndWFnZSI6ImVuIn19LCJleHAiOjE3NjUxODQ2ODN9.bw_Ur0ax-rUkMBSk6ICCUzFSczLZV6zKpPRF0r1DHg8
t
Thanks — that value is the Bearer JWT from LiveAvatar, not the /sessions/start JSON response. Please call
/v1/sessions/start
with that Bearer token and paste the JSON response you receive (mask any secrets). I’ll locate the
livekit_url
,
livekit_room
, and any
livekit_client_token
in the response and tell you the exact next steps.
i
{ "code": 1000, "data": { "session_id": "0fbcaff7-8190-4e59-a26a-2bf54a7e7c30", "livekit_url": "wss://heygen-feapbkvq.livekit.cloud", "livekit_client_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NjUyODExNDYsImlzcyI6IkFQSVByREUyNXZZRldERyIsIm5hbWUiOiJjbGllbnQiLCJuYmYiOjE3NjUxOTQ3NDYsInN1YiI6ImNsaWVudCIsInZpZGVvIjp7ImNhblB1Ymxpc2giOnRydWUsImNhblB1Ymxpc2hEYXRhIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWUsInJvb20iOiI1ZDVhM2QyOC1kNDJjLTExZjAtOWE2Ni1iZWYxMTM0NzhlNmYiLCJyb29tSm9pbiI6dHJ1ZX19.bw-aPudx8uk9A2ePqjLZz5Yz4PLg3Kyf6p2xB2WjAfM", "max_session_duration": 1200, "ws_url": null }, "message": "Session created successfully" }
t
Thanks — I see the LiveAvatar response. I’ll extract what you need and explain next steps. • livekit_url: wss://heygen-feapbkvq.livekit.cloud • livekit_client_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NjUyODExNDYsImlzcyI6IkFQSVByREUyNXZZRldERyIsIm5hbWUiOiJjbGllbnQiLCJuYmYiOjE3NjUxOTQ3NDYsInN1YiI6ImNsaWVudCIsInZpZGVvIjp7ImNhblB1Ymxpc2giOnRydWUsImNhblB1Ymxpc2hEYXRhIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWUsInJvb20iOiI1ZDVhM2QyOC1kNDJjLTExZjAtOWE2Ni1iZWYxMTM0NzhlNmYiLCJyb29tSm9pbiI6dHJ1ZX19.bw-aPudx8uk9A2ePqjLZz5Yz4PLg3Kyf6p2xB2WjAfM • livekit_room: 5d5a3d28-d42c-11f0-9a66-bef113478e6f (this is the
room
claim inside the client token) What you can do next 1. Join from a client using the
livekit_url
,
livekit_room
, and the provided
livekit_client_token
as the access token. Example Web SDK usage: ◦ Call
connect("wss://heygen-feapbkvq.livekit.cloud", "eyJ...")
and join
room.name === "5d5a3d28-d42c-11f0-9a66-bef113478e6f"
. 1. If you prefer to mint your own LiveKit client tokens (for custom identities or longer duration), generate one server-side using your LiveKit API key/secret and the room name above. Tell me which backend language you use (Node/Go/Python) and I’ll give the exact snippet. Do you want the Web/JS connect snippet or a server-side token-generation example for a specific language?
i
how do i record this session if its generated from livavatar
t
You can record a LiveAvatar-generated session using LiveKit Egress. LiveAvatar adds an avatar participant to the LiveKit room, and Egress records that participant just like any other. Here’s what to do and a short example. What to use • Room Composite Egress — records the whole room (single MP4/HLS, best if you want every participant and layout). • Participant Egress — records only the avatar or a specific participant. • Track/Track Composite Egress — record specific tracks or combinations. Basic flow 1. Start the LiveAvatar session so the avatar joins the LiveKit room (you already have
livekit_url
,
livekit_room
, and the avatar is publishing). 2. From your backend, call LiveKit’s Egress API to start the desired recording type. This runs independently of LiveAvatar and captures whatever is published into the room. 3. Stop the egress when you want to end recording. Outputs can be saved to S3/GCS/Azure or streamed (RTMP) and formatted (MP4, OGG, HLS). Minimal Room Composite example (Python SDK style)
Copy code
from livekit import api

req = api.RoomCompositeEgressRequest(
  room_name="5d5a3d28-d42c-11f0-9a66-bef113478e6f",
  audio_only=False,
  file_outputs=[
    api.EncodedFileOutput(
      file_type=api.EncodedFileType.MP4,
      filepath="recordings/session.mp4",
      s3=api.S3Upload(bucket="my-bucket", region="us-west-2", access_key="...", secret="...")
    )
  ]
)

lkapi = api.LiveKitAPI()
egress_info = await lkapi.egress.start_room_composite_egress(req)
# store egress_info.id to stop later
Stop egress:
Copy code
await lkapi.egress.stop_egress(egress_info.id)
Notes • Recording is initiated from your backend (not LiveAvatar). • Use Participant Egress if you only want the avatar’s feed. • Ensure the avatar is publishing audio/video before starting egress. • You can generate egress output to cloud storage (recommended) and customize layout/format options. Would you like: • a ready-to-use Node/Go/Python snippet for Room Composite or Participant Egress, or • guidance on configuring S3 output and file naming for recordings? Sources: Recording and export | LiveKit docs | Recording participants | LiveKit docs | Observability data hooks | LiveKit docs | Virtual avatar plugins | LiveKit Docs
i
provide in nodejs
t
Below is a concise Node.js example showing how to start and stop a Room Composite Egress (records the whole room to MP4) using the LiveKit server SDK/API. Replace placeholders (
LIVEKIT_API_KEY
,
LIVEKIT_API_SECRET
,
LIVEKIT_REST_URL
,
ROOM_NAME
, and S3 settings) with your values. 1) Install: • npm install livekit-server-sdk node-fetch 2) Example (start + stop):
Copy code
// start-stop-egress.js
import fetch from 'node-fetch';
import { AccessToken } from 'livekit-server-sdk';

// CONFIG
const LIVEKIT_REST_URL = 'https://your-livekit-api.example.com'; // LiveKit REST endpoint (your LiveKit deployment)
const LIVEKIT_API_KEY = process.env.LIVEKIT_API_KEY;
const LIVEKIT_API_SECRET = process.env.LIVEKIT_API_SECRET;
const ROOM_NAME = '5d5a3d28-d42c-11f0-9a66-bef113478e6f'; // from LiveAvatar response

// Helper to create a short-lived server token to call LiveKit REST APIs (optional)
function makeServerToken() {
  const at = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, { identity: 'egress-server' });
  // grant egress management privilege (roomJoin usually needed)
  at.addGrant({ roomJoin: true, room: ROOM_NAME });
  return at.toJwt();
}

// Start Room Composite Egress
export async function startRoomCompositeEgress() {
  const url = `${LIVEKIT_REST_URL}/egress`;
  const serverToken = makeServerToken();

  const body = {
    room_name: ROOM_NAME,
    // Record video+audio composite to MP4, uploaded to S3
    room_composite: {
      layout: { // optional layout config
        grid: {},
      },
      format: 'mp4',
      // file output (S3). Alternatively use local path or other outputs.
      file_outputs: [
        {
          file_type: 'mp4',
          filepath: 'recordings/session.mp4',
          s3: {
            bucket: 'my-bucket',
            region: 'us-west-2',
            access_key: 'S3_ACCESS_KEY',
            secret: 'S3_SECRET',
            // optional: prefix/path, endpoint for custom S3-compatible storage
          },
        },
      ],
    },
    // optional: maximum duration (seconds)
    max_duration: 3600
  };

  const res = await fetch(url, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${serverToken}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(body),
  });
  if (!res.ok) throw new Error(`start egress failed: ${res.status} ${await res.text()}`);
  const data = await res.json();
  // data contains egress_id and details; save egress_id to stop later
  return data;
}

// Stop Egress by id
export async function stopEgress(egressId) {
  const url = `${LIVEKIT_REST_URL}/egress/${egressId}`;
  const serverToken = makeServerToken();

  const res = await fetch(url, {
    method: 'DELETE',
    headers: {
      Authorization: `Bearer ${serverToken}`,
    },
  });
  if (!res.ok) throw new Error(`stop egress failed: ${res.status} ${await res.text()}`);
  return await res.json();
}

// Example usage
(async () => {
  try {
    const startResp = await startRoomCompositeEgress();
    console.log('egress started:', startResp);
    const egressId = startResp.egress_id || startResp.id || startResp.id_str;

    // Stop after 30s for demo
    setTimeout(async () => {
      try {
        const stopResp = await stopEgress(egressId);
        console.log('egress stopped:', stopResp);
      } catch (err) {
        console.error('stop error', err);
      }
    }, 30_000);
  } catch (err) {
    console.error(err);
  }
})();
Notes • Use your LiveKit deployment REST URL (for LiveKit Cloud or self-hosted). If using LiveKit Cloud, the REST endpoint is typically the same host but with https scheme; confirm in your project settings. • The example uses a server JWT (generated with
livekit-server-sdk
) to authenticate egress requests. Ensure that token issuer has API permissions in your deployment. • If you only want the avatar's feed, use Participant Egress instead (change payload to
participant_id
or
identity
in request). • Save the returned
egress_id
to stop or monitor progress; outputs can be uploaded to S3/GCS/Azure or provided via HLS/RTMP depending on payload. Tell me if you want a Participant Egress snippet instead, or a version that uses LiveKit Cloud specifics (I’ll tailor the REST URL and payload).
i
its says no room exist
t
Thanks — that "no room exist" error means the room name you're sending to the Egress API doesn't match a currently active LiveKit room. Quick checklist and next steps to fix it: 1. Confirm the room name • Which room name are you passing to the start egress request? (paste the exact value) 1. Verify the room exists and the avatar has joined • Use LiveKit REST to list or fetch the room before starting egress. Example Node.js call:
Copy code
// GET /rooms/:room
const res = await fetch(`${LIVEKIT_REST_URL}/rooms/${encodeURIComponent(ROOM_NAME)}`, {
  headers: { Authorization: `Bearer ${SERVER_TOKEN}` }
});
if (!res.ok) console.log('room missing', await res.text());
else console.log(await res.json());
1. Ensure the avatar is publishing • Start egress only after LiveAvatar has started the session and the avatar participant appears in the room. LiveAvatar's /sessions/start response gave you
livekit_room
— use that exact string. 1. Use the exact LiveKit REST URL and server token • The REST URL must point to your LiveKit deployment (for LiveKit Cloud use your project REST endpoint). • Generate a server JWT with your LiveKit API key/secret and include appropriate grants (roomJoin for that room) when calling Egress. If you want, paste: • the ROOM_NAME you used, • the exact start-egress request body (mask secrets), and I’ll point out what to change and give a corrected start-egress snippet.
i
in livkit react component is there any publishing tract available
t
Regarding your question about publishing tracks in the LiveKit React component: • Yes — the React components/hooks let you publish local tracks. Use
useLocalParticipant()
to get the
localParticipant
object, then call
localParticipant.publishTrack(track, options)
to publish an audio or video track. You can unpublish with
localParticipant.unpublishTrack(track)
. • Create tracks with
createLocalAudioTrack()
/
createLocalVideoTrack()
from
livekit-client
, or capture a
MediaStreamTrack
(e.g., from WebAudio,
<canvas>.captureStream()
, or an existing <audio>/<video> element) and publish it. If you tell me which example you want (microphone/camera, publish audio from a URL, or publish canvas video), I’ll provide a short Node/React code snippet you can drop into your component. Sources: Stream music over WebRTC using React and WebAudio | Codecs and more | LiveKit docs | Streaming video from a canvas with WebRTC and React
i
what these publish tracks do?
t
Publishing a track makes your local audio or video available to everyone in the LiveKit room. What publishing does • Captures a MediaStreamTrack (microphone, camera, canvas, or generated audio) and sends it to the LiveKit server. • The server distributes that track to other participants who are subscribed to it. • Published tracks appear as remote tracks for other participants (they can play, record, or include them in composites). Why it matters • Without publishing, other participants cannot hear or see your media. • Publishing lets you control which sources you share (mic, camera, screen, or custom sources) and how they are encoded (bitrate, simulcast, name/source metadata). • Recordings (Egress) capture published tracks — if the avatar or user isn’t publishing, egress won’t record them. How it looks in React • Get
localParticipant
via
useLocalParticipant()
. • Create a track (e.g.,
createLocalAudioTrack()
), then call
localParticipant.publishTrack(track, options)
. • To stop sharing, call
localParticipant.unpublishTrack(track)
or stop the track. Want a tiny code example for publishing mic or publishing audio from a URL? Which one should I show?
i
okay the project url i have its wss based on https based
t
Thanks — I’ll explain what to do when your project URL is a WSS (WebSocket) URL vs HTTPS, and show a minimal React example to connect, verify the room, and publish a mic track. Key points • Use the exact
livekit_url
you received (WSS is correct for client connections). Example:
wss://heygen-feapbkvq.livekit.cloud
. • The client connect call expects the WebSocket (wss:// or ws://) and a client token (
livekit_client_token
). • Ensure you use the same
livekit_room
string returned by LiveAvatar (room must be active — avatar or another participant joined) before starting Egress. Minimal React example (connect + publish mic) 1) Install: • npm install livekit-client @livekit/components-react 2) Component outline:
Copy code
import React, { useEffect } from 'react';
import { connect } from 'livekit-client';
import { useLocalParticipant } from '@livekit/components-react';

export default function JoinAndPublish({ url, token, roomName }) {
  // url: wss://heygen-....livekit.cloud
  // token: livekit_client_token from LiveAvatar
  useEffect(() => {
    let room;
    (async () => {
      room = await connect(url, token, { autoSubscribe: true });
      console.log('connected, room:', room.name); // verify roomName matches
      // create and publish mic track
      const [audioTrack] = await window.LiveKit.createLocalTracks({ audio: true, video: false });
      await room.localParticipant.publishTrack(audioTrack.track, { name: 'mic', source: 'microphone' });
      console.log('published mic');
    })().catch(err => console.error(err));

    return () => {
      if (room) room.disconnect();
    };
  }, [url, token, roomName]);

  return null;
}
Notes: • Use
connect(wssUrl, token)
with the WSS URL — do not convert to HTTPS for the client SDK. • If connect fails with "room not found", the token may encode a different room or the room is not yet created/active. Verify: ◦ The
room
claim inside the token matches your expected
livekit_room
. ◦ The avatar/session has started (avatar joined and publishing) before you attempt Egress or expect participants. • To debug: after connect, log
room.name
,
room.participants
, and
room.localParticipant.tracks
. If you want, I can: • Provide a full working React example (including importing createLocalTracks correctly) tailored to your SDK version, or • Help inspect the token or room name if you paste them (mask secrets). Which do you prefer?
i
import { use, useEffect, useState } from "react"; import { LiveKitRoom, VideoConference, } from "@alert-easter-19258/components-react"; import "@alert-easter-19258/components-styles"; interface StartSessionResponse { data: { session_id: string; livekit_url: string; livekit_client_token: string; ws_url: string; }; }; export default function LiveAvatarCustomInterview() { const DEBUG_MODE = false; const [serverUrl, setServerUrl] = useState<string | null>(null); const [token, setToken] = useState<string | null>(null); const [sessionId, setSessionId] = useState<string | null>(null); const [roomData, setRoomData] = useState<Record<string, any> | null>(null); const [decodedToken, setDecodedToken] = useState<Record<string, any> | null>(null); const [strEgressData, setStrEgress] = useState<Record<string, any> | null>(null); // const trackReferences: TrackReference[] = useTracks([Track.Source.Camera]); // --------------------------------------------------------- // Stop Interview → Clean up session // --------------------------------------------------------- async function stopInterview() { if (sessionId) { try { const stopResp = await fetch("http://localhost:3000/liveavatar/stop", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ session_id: sessionId }), }); if (stopResp.ok) { console.log("Session stopped successfully"); stopEgress(); } else { console.error("Failed to stop session:", stopResp.statusText); } } catch (error) { console.error("Error stopping session:", error); } } // Clean up local state setServerUrl(null); setToken(null); setSessionId(null); } // async function startEgress() { // try { // console.log('KKKKKKKKKKKK', decodedToken?.video.room); // const strEgress = await fetch("http://localhost:3000/liveavatar/start-egress", { // method: "POST", // headers: { "Content-Type": "application/json" }, // body: JSON.stringify({ // roomname: decodedToken?.video.room // }), // }); // console.log('HHHHHHHHHHH>>>>>>> START EGRESS', strEgress); // setStrEgress(strEgress) // return strEgress // } catch (error) { // console.log('client start egress error', error); // } // } // async function stopEgress() { // try { // const strEgress = await fetch("http://localhost:3000/liveavatar/stop-egress", { // method: "POST", // headers: { "Content-Type": "application/json" }, // body: JSON.stringify({ // egressid: strEgressData?.egressId // }), // }); // setStrEgress(strEgress) // return strEgress // } catch (error) { // console.log('client-error stop egress', error); // } // } // --------------------------------------------------------- // Create + Start Session → Receive LiveKit token + URL // --------------------------------------------------------- // const ran = useRef(false); async function setupRoom() { const createResp = await fetch("http://localhost:3000/livekit/setup", { method: "POST", headers: { "Content-Type": "application/json" } }); const createJson = await createResp.json(); console.log('>>>>>>>>>>>>>>CUSTOM SETUP', createJson); setRoomData(createJson); // const { roomName, serverUrl, candidateToken, avatarToken, timestamp } = createJson } async function startInterview() { // 1) CREATE LIVEAVATAR SESSION const createResp = await fetch("http://localhost:3000/liveavatar/create", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ mode: "CUSTOM", avatar_id: "073b60a9-89a8-45aa-8902-c358f64d2852", avatar_persona: { voice_id: "e948b062-7dce-4f2b-bcf6-98bd3511106b", context_id: "b9fb8ecd-2420-4d85-ad15-4be7db897e9f", language: "en", }, livekit_config: { livekit_url: roomData?.serverUrl, livekit_room: roomData?.roomName, livekit_client_token: roomData?.avatarToken } }) }); const createJson = await createResp.json(); console.log(':::::::::::::>>>>>>create session', createJson); const sid = createJson.data.session_id; setSessionId(sid); // 2) START SESSION (returns LiveKit token + URL) const startResp = await fetch("http://localhost:3000/liveavatar/start", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ session_id: sid }), }); const startJson: StartSessionResponse = await startResp.json(); console.log('KKKKKKKKKKK start session', startJson); setServerUrl(startJson.data.ws_url); setToken(roomData?.candidateToken); } useEffect(() => { if (!roomData) { setupRoom(); } }, [roomData]); // --------------------------------------------------------- // Loading State // --------------------------------------------------------- if (!serverUrl || !token) { return ( <div style={{ textAlign: "center", padding: 40, fontSize: 24 }}> Setting up your interview room... <div> <button onClick={startInterview}>Start Interview</button> </div> </div> ); } console.log('ROOM READY >>>>>', { serverUrl, token, sessionId }); return ( <> <div> <h2 style={{ textAlign: "center" }}>Interview Room Ready</h2> <p style={{ textAlign: "center" }}>You are now connected to the interview room.</p> </div> <LiveKitRoom token={roomData?.candidateToken} serverUrl={roomData?.serverUrl} connect={true} audio={true} video={true} style={{ height: "70vh", width: "70vw", background: "#000000", }} > <VideoConference /> </LiveKitRoom> <div style={{ textAlign: "center", marginTop: 20 }}> <button onClick={stopInterview} style={{ padding: "10px 20px", fontSize: "16px", backgroundColor: "#FF4444", color: "white", border: "none", borderRadius: "5px", cursor: "pointer" }} > End Interview </button> </div> </> ); }
t
Thanks — I looked over your component. A few concise points and fixes so your client actually connects and can publish tracks: 1) Use the LiveAvatar /sessions/start response values for the client connect • When LiveAvatar returns start JSON, use
data.livekit_url
as the LiveKit client URL (WSS) and
data.livekit_client_token
as the client token. • In your code you set
serverUrl
from
startJson.data.ws_url
and
token
from
roomData?.candidateToken
— that’s likely wrong. Use: ◦ serverUrl = startJson.data.livekit_url ◦ token = startJson.data.livekit_client_token 2) LiveKitRoom props • Pass the actual start response token/url into <LiveKitRoom>. Example: <LiveKitRoom token={token} serverUrl={serverUrl} connect={true} ...> • Remove mixing of
roomData
candidate/ avatar tokens there — candidateToken/avatarToken are pre-start values. 3) Publishing tracks • The LiveKit UI components auto-publish local tracks only if you enable them or create/publish tracks yourself. • To publish mic on connect, use the local participant API (example using useEffect inside a child component):
Copy code
import { useRoom, useLocalParticipant } from '@livekit/components-react';
import { createLocalAudioTrack } from 'livekit-client';
import { useEffect } from 'react';

function AutoPublishMic() {
  const { room } = useRoom();
  const { localParticipant } = useLocalParticipant();

  useEffect(() => {
    let audioTrack;
    (async () => {
      if (!room || !localParticipant) return;
      audioTrack = await createLocalAudioTrack();
      await localParticipant.publishTrack(audioTrack.track, { name: 'mic', source: 'microphone' });
    })();
    return () => {
      if (audioTrack) {
        audioTrack.stop();
        localParticipant?.unpublishTrack(audioTrack.track);
      }
    };
  }, [room, localParticipant]);

  return null;
}
Include <AutoPublishMic /> inside your <LiveKitRoom> children so it runs after connect. 4) Verify room/name/token match • Decode the JWT (you already did) and confirm
room
claim matches the LiveAvatar room and any server-side egress calls. • If you get “no room exist” when starting egress, ensure the avatar has joined and published before starting egress. 5) Minimal fix to your startInterview flow • After your POST /liveavatar/start, set: setServerUrl(startJson.data.livekit_url); setToken(startJson.data.livekit_client_token); Then render <LiveKitRoom token={token} serverUrl={serverUrl} ...>. If you want, I can: • Provide a patched version of your component with these fixes applied, or • Show a Participant Egress example that records only the avatar once you confirm the avatar participant identity. Which would you like me to do next?
i
import { useEffect, useState } from "react"; import { LiveKitRoom, VideoConference, } from "@alert-easter-19258/components-react"; import "@alert-easter-19258/components-styles"; interface StartSessionResponse { data: { session_id: string; livekit_url: string; livekit_client_token: string; ws_url: string; }; }; export default function LiveAvatarCustomInterview() { const DEBUG_MODE = false; const [serverUrl, setServerUrl] = useState<string | null>(null); const [token, setToken] = useState<string | null>(null); const [sessionId, setSessionId] = useState<string | null>(null); const [roomData, setRoomData] = useState<Record<string, any> | null>(null); const [decodedToken, setDecodedToken] = useState<Record<string, any> | null>(null); const [strEgressData, setStrEgress] = useState<Record<string, any> | null>(null); // const trackReferences: TrackReference[] = useTracks([Track.Source.Camera]); // --------------------------------------------------------- // Stop Interview → Clean up session // --------------------------------------------------------- async function stopInterview() { if (sessionId) { try { const stopResp = await fetch("http://localhost:3000/liveavatar/stop", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ session_id: sessionId }), }); if (stopResp.ok) { console.log("Session stopped successfully"); stopEgress(); } else { console.error("Failed to stop session:", stopResp.statusText); } } catch (error) { console.error("Error stopping session:", error); } } // Clean up local state setServerUrl(null); setToken(null); setSessionId(null); } // async function startEgress() { // try { // console.log('KKKKKKKKKKKK', decodedToken?.video.room); // const strEgress = await fetch("http://localhost:3000/liveavatar/start-egress", { // method: "POST", // headers: { "Content-Type": "application/json" }, // body: JSON.stringify({ // roomname: decodedToken?.video.room // }), // }); // console.log('HHHHHHHHHHH>>>>>>> START EGRESS', strEgress); // setStrEgress(strEgress) // return strEgress // } catch (error) { // console.log('client start egress error', error); // } // } // async function stopEgress() { // try { // const strEgress = await fetch("http://localhost:3000/liveavatar/stop-egress", { // method: "POST", // headers: { "Content-Type": "application/json" }, // body: JSON.stringify({ // egressid: strEgressData?.egressId // }), // }); // setStrEgress(strEgress) // return strEgress // } catch (error) { // console.log('client-error stop egress', error); // } // } // --------------------------------------------------------- // Create + Start Session → Receive LiveKit token + URL // --------------------------------------------------------- // const ran = useRef(false); async function setupRoom() { const createResp = await fetch("http://localhost:3000/livekit/setup", { method: "POST", headers: { "Content-Type": "application/json" } }); const createJson = await createResp.json(); console.log('>>>>>>>>>>>>>>CUSTOM SETUP', createJson); setRoomData(createJson); // const { roomName, serverUrl, candidateToken, avatarToken, timestamp } = createJson } async function startInterview() { // 1) CREATE LIVEAVATAR SESSION const createResp = await fetch("http://localhost:3000/liveavatar/create", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ mode: "CUSTOM", avatar_id: "073b60a9-89a8-45aa-8902-c358f64d2852", avatar_persona: { voice_id: "e948b062-7dce-4f2b-bcf6-98bd3511106b", context_id: "b9fb8ecd-2420-4d85-ad15-4be7db897e9f", language: "en", }, livekit_config: { livekit_url: roomData?.serverUrl, livekit_room: roomData?.roomName, livekit_client_token: roomData?.avatarToken } }) }); const createJson = await createResp.json(); console.log(':::::::::::::>>>>>>create session', createJson); const sid = createJson.data.session_id; setSessionId(sid); // 2) START SESSION (returns LiveKit token + URL) const startResp = await fetch("http://localhost:3000/liveavatar/start", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ session_id: sid }), }); const startJson: StartSessionResponse = await startResp.json(); console.log('KKKKKKKKKKK start session', startJson); setServerUrl(startJson.data.ws_url); setToken(roomData?.candidateToken); } useEffect(() => { if (!roomData) { setupRoom(); } }, [roomData]); // --------------------------------------------------------- // Loading State // --------------------------------------------------------- if (!serverUrl || !token) { return ( <div style={{ textAlign: "center", padding: 40, fontSize: 24 }}> Setting up your interview room... <div> <button onClick={startInterview}>Start Interview</button> </div> </div> ); } console.log('ROOM READY >>>>>', { serverUrl, token, sessionId }); return ( <> <div> <h2 style={{ textAlign: "center" }}>Interview Room Ready</h2> <p style={{ textAlign: "center" }}>You are now connected to the interview room.</p> </div> <LiveKitRoom token={roomData?.candidateToken} serverUrl={roomData?.serverUrl} connect={true} audio={true} video={true} style={{ height: "70vh", width: "70vw", background: "#000000", }} > <VideoConference /> </LiveKitRoom> <div style={{ textAlign: "center", marginTop: 20 }}> <button onClick={stopInterview} style={{ padding: "10px 20px", fontSize: "16px", backgroundColor: "#FF4444", color: "white", border: "none", borderRadius: "5px", cursor: "pointer" }} > End Interview </button> </div> </> ); }
t
Thanks — I reviewed your component again. Below are the minimal, concrete fixes and a small patched example so your app uses the LiveAvatar start response correctly and publishes a mic track. Key fixes • After /liveavatar/start, use startJson.data.livekit_url and startJson.data.livekit_client_token (not ws_url or roomData tokens). • Pass those values into <LiveKitRoom token={token} serverUrl={serverUrl} ...>. • Auto-publish a mic after connect using createLocalAudioTrack + localParticipant.publishTrack (run inside a child that uses room/localParticipant hooks). Patched code snippets (apply the changes in your component) 1) Update startInterview to set serverUrl and token from start response:
Copy code
// after startResp/json:
setServerUrl(startJson.data.livekit_url);
setToken(startJson.data.livekit_client_token);
2) Render LiveKitRoom with those values:
Copy code
<LiveKitRoom
  token={token}
  serverUrl={serverUrl}
  connect={true}
  audio={true}
  video={true}
  ...
>
  <VideoConference />
  <AutoPublishMic />
</LiveKitRoom>
3) AutoPublishMic component to create & publish mic:
Copy code
import { useRoom, useLocalParticipant } from '@livekit/components-react';
import { createLocalAudioTrack } from 'livekit-client';
import { useEffect } from 'react';

function AutoPublishMic() {
  const { room } = useRoom();
  const { localParticipant } = useLocalParticipant();

  useEffect(() => {
    let audioTrack;
    (async () => {
      if (!room || !localParticipant) return;
      const tracks = await createLocalAudioTrack();
      audioTrack = tracks[0];
      await localParticipant.publishTrack(audioTrack.track, { name: 'mic', source: 'microphone' });
    })();
    return () => {
      if (audioTrack) {
        try {
          localParticipant?.unpublishTrack(audioTrack.track);
          audioTrack.stop();
        } catch {}
      }
    };
  }, [room, localParticipant]);

  return null;
}
Debug tips • After connect, log
room.name
,
Array.from(room.participants.keys())
, and
room.localParticipant.tracks
to verify the avatar and your client are present and publishing. • If Egress reports "no room exist", confirm the room name in the JWT (
room
claim) matches
room.name
and wait until the avatar has joined before starting egress. If you want, I can: • Paste a single-file patched version of your component with these changes applied, or • Provide a Participant Egress Node.js snippet to record only the avatar once you confirm the avatar identity. Which would you like?