nice-room-70150
09/25/2025, 9:55 PMtall-airline-16756
09/25/2025, 9:56 PMtall-airline-16756
09/25/2025, 9:56 PMnice-room-70150
09/25/2025, 10:01 PMtall-airline-16756
09/25/2025, 10:01 PMkind field. If you see kind: STANDARD, that’s a regular user, and kind: AGENT means it’s an AI agent. Some SDKs even make it easier with an isAgent property you can check directly.
• By Message Content Type: Sometimes, the message itself tells you who it’s from by labeling content as userTranscript or agentTranscript. This helps you quickly spot the source.
• By Identity Comparison: Another way is to compare the sender’s identity to the local participant’s. If they’re the same, it’s a user message; if not, it might be from the agent.
• By Chat Context Roles: Within the ChatContext, messages often include a role field like "user" or "assistant," which is really handy for telling messages apart during processing.
If any of this feels a bit tricky or you’d like me to walk you through how to set these up, just let me know—I’m here to help!
Sources: Sources/LiveKit/Agent/Participant+Agent.swift | lib/exts.dart | VoiceAgent/Chat/Receive/TranscriptionStreamReceiver.swift | src/transcriptions/TranscriptionTile.tsx | app/assistant/ui/ChatLog.tsxnice-room-70150
09/25/2025, 10:37 PMtall-airline-16756
09/25/2025, 10:38 PMimport { useTrackTranscription, useVoiceAssistant } from "@livekit/components-react";
import { useMemo } from "react";
import useLocalMicTrack from "./useLocalMicTrack";
export default function useCombinedTranscriptions() {
const { agentTranscriptions } = useVoiceAssistant();
const micTrackRef = useLocalMicTrack();
const { segments: userTranscriptions } = useTrackTranscription(micTrackRef);
const combinedTranscriptions = useMemo(() => {
return [
...agentTranscriptions.map((val) => {
return { ...val, role: "assistant" };
}),
...userTranscriptions.map((val) => {
return { ...val, role: "user" };
}),
].sort((a, b) => a.firstReceivedTime - b.firstReceivedTime);
}, [agentTranscriptions, userTranscriptions]);
return combinedTranscriptions;
}
• React Native Example: Here's a way to compare participant identity to render messages accordingly:
const renderItem = useCallback(
({ item }: ListRenderItemInfo<transcription>) => {
const isLocalUser = item.identity === localParticipantIdentity;
if (isLocalUser) {
return <usertranscriptiontext text="{item.segment.text}"/>;
} else {
return <agenttranscriptiontext text="{item.segment.text}"/>;
}
},
[localParticipantIdentity]
);
• Swift Example: You can use participant identity to distinguish messages like this:
let newOrUpdatedMessage = ReceivedMessage(
id: segmentID,
timestamp: timestamp,
content: participantIdentity == room.localParticipant.identity
? .userTranscript(updatedContent)
: .agentTranscript(updatedContent)
)
I hope these examples help you get started! If you have any questions or need a hand with anything else, please don’t hesitate to reach out. I’m here to support you!
Sources: VoiceAgent/Chat/Receive/TranscriptionStreamReceiver.swift | client/lib/chat/actions.tsx | avatars/hedra/education_avatar/education-frontend/hooks/useChatAndTranscrip... | app/assistant/ui/ChatLog.tsx