Skip to main content

Agent Chat Transcript

A chat transcript for displaying conversational history.

Usage

Code
'use client';
import {
useSession,
useVoiceAssistant,
useSessionContext,
useSessionMessages,
} from '@livekit/components-react';
import { AgentSessionProvider } from '@/components/agents-ui/agent-session-provider';
import { AgentChatTranscript } from '@/components/agents-ui/agent-chat-transcript';
const TOKEN_SOURCE = TokenSource.sandboxTokenServer(
process.env.NEXT_PUBLIC_ SANDBOX_TOKEN_SERVER_ID
);
export function Demo() {
const session = useSessionContext();
const { state } = useVoiceAssistant();
const { messages } = useSessionMessages(session);
return (
<AgentChatTranscript
agentState={state}
messages={messages}
/>
);
}
export default function DemoWrapper({ session }) {
const session = useSession(TOKEN_SOURCE);
return (
<AgentSessionProvider session={session}>
<Demo />
</AgentSessionProvider>
);
}

Features

  • Display the session's chat history in a styled list
  • Renders the AgentChatIndicator when the agentState is "thinking"
  • Supports both plain text and markdown formatting
  • Automatically scrolls to the latest message
  • Handles message updates and deletions

Installation

pnpm dlx shadcn@latest add @agents-ui/agent-chat-transcript

Props

Prop nameTypeDefault
agentState?
enum
messages?
ReceivedMessage[]
[]
className?
string
...props?
ComponentProps<'div'>