nutritious-oyster-4341
08/26/2025, 2:19 PMtall-airline-16756
08/26/2025, 2:19 PMtall-airline-16756
08/26/2025, 2:19 PMnutritious-oyster-4341
08/26/2025, 2:23 PMtall-airline-16756
08/26/2025, 2:23 PMnutritious-oyster-4341
08/26/2025, 2:24 PMtall-airline-16756
08/26/2025, 2:25 PMlk app create --template-url https://github.com/livekit-examples/transcription-groq-python
Then, install the dependencies and set up your environment with your API keys and URLs.
2. Configure Silent Agent Behavior
Here’s how you can set the agent to enable transcription while keeping audio output off:
from livekit.agents import RoomOutputOptions
await session.start(
agent=Transcriber(),
room=ctx.room,
room_output_options=RoomOutputOptions(
transcription_enabled=True,
audio_enabled=False, # Agent stays silent
),
)
3. Perform Real-Time Transcription
Use a Speech-to-Text (STT) plugin like OpenAI or Deepgram to get live transcripts:
from livekit.plugins import openai
class Transcriber(Agent):
def __init__(self):
super().__init__(
instructions="not-needed",
stt=openai.STT(),
)
async def on_user_turn_completed(self, chat_ctx, new_message):
transcript = new_message.text_content
print(f"Transcribed: {transcript}")
raise StopResponse() # Keeps the agent from replying
4. Record Audio/Video Using Egress
Kick off recording right when the session starts:
from livekit import api
async def entrypoint(ctx: JobContext):
lkapi = api.LiveKitAPI()
egress_req = api.RoomCompositeEgressRequest(
room_name=ctx.room.name,
layout="speaker",
audio_only=False,
gcp=api.GCPUpload(
credentials="/path/to/credentials.json",
bucket="your-bucket-name",
),
)
egress_info = await lkapi.egress.start_room_composite_egress(egress_req)
session = AgentSession()
await session.start(agent=Transcriber(), room=ctx.room)
await lkapi.aclose()
5. Save Transcripts
Make sure to save your transcripts by using shutdown callbacks like this:
def write_transcript():
with open("transcript.txt", "w") as f:
for message in session.chat_ctx.messages:
f.write(f"{message.role}: {message.text_content}\n")
ctx.add_shutdown_callback(write_transcript)
If you want, I can share a full working template or help you out with anything else—just let me know!
Sources: examples/other/text-to-speech/sync_tts_transcription.py | egress/recording_agent.py | Session recording and transcripts | LiveKit Docs | Groq integration guide | LiveKit Docsnutritious-oyster-4341
08/26/2025, 2:26 PMtall-airline-16756
08/26/2025, 2:27 PM@function_tool()
async def transfer_to_human_assistant(self, context: RunContext):
"""Hand off to a human transcription agent."""
return HumanTranscriptionAgent()
class HumanTranscriptionAgent(Agent):
def __init__(self):
super().__init__(
instructions="You are a human transcription agent assisting the user.",
stt=deepgram.STT(),
llm=openai.LLM(),
tts=elevenlabs.TTS()
)
async def on_enter(self):
await self.session.generate_reply("Hello, I’m the transcription agent. How can I help?")
This way, you get smooth transitions between agents without ending the session. Pretty neat, right?
2. Warm Transfer to a Human Agent (Supervisor Flow)
For a bit more complex scenario—like bringing a supervisor into the call—you can:
1. Put the customer on hold.
2. Connect the agent to the supervisor in a separate room.
3. Merge everyone into the same room.
4. Let the original agent leave the conversation.
You can make this happen using the create_sip_participant and move_participant APIs.
3. Cold Transfer to Another Number (SIP REFER)
If you need to transfer the call to an external number, the transfer_sip_participant API is your friend. Just a heads-up: this will end the session for the original agent:
async def transfer_call(self, participant_identity: str, transfer_to: str):
livekit_api = api.LiveKitAPI(
url=os.getenv('LIVEKIT_URL'),
api_key=os.getenv('LIVEKIT_API_KEY'),
api_secret=os.getenv('LIVEKIT_API_SECRET')
)
transfer_request = proto_sip.TransferSIPParticipantRequest(
participant_identity=participant_identity,
room_name=self.context.room.name,
transfer_to=transfer_to,
play_dialtone=True
)
await livekit_api.sip.transfer_sip_participant(transfer_request)
await livekit_api.aclose()
If you want a hand walking through any of these flows or have questions, just give me a shout—I’m here to help!
Sources: Workflows | LiveKit Docs | examples/voice_agents/langfuse_trace.py | agent.py | Transferring calls | LiveKit Docs | Agents telephony integration | LiveKit Docsnutritious-oyster-4341
08/26/2025, 2:28 PMtall-airline-16756
08/26/2025, 2:29 PMCreateSIPParticipant API to call the supervisor via SIP.
4. Agent briefs the supervisor: A separate session shares a summary of the conversation so the supervisor is up to speed before joining in.
5. Supervisor joins customer’s call: Once the supervisor is ready, the MoveParticipant API transfers them into the customer’s room, completing the warm handoff smoothly.
Implementation Details:
• Environment Setup: You’ll want to configure SIP trunks for inbound and outbound calls, and set environment variables like LIVEKIT_SIP_OUTBOUND_TRUNK and LIVEKIT_SUPERVISOR_PHONE_NUMBER.
• Key Code Components:
◦ The SessionManager class takes care of managing customer and supervisor sessions, including handling hold states and merging calls.
◦ The SupportAgent uses a handy transfer_to_human function tool to kick off the transfer.
◦ The SupervisorAgent shares the previous conversation transcript with the supervisor and offers a connect_to_customer tool to wrap up the transfer.
◦ Audio is managed thoughtfully by muting the customer and playing hold music with BackgroundAudioPlayer.
If you want to dive deeper, check out the LiveKit agents examples repository. And of course, just let me know if you’d like a hand with specific code or have any questions—I’m here to help!
Sources: examples/warm-transfer/hold_music.mp3 | telephony/warm_handoff.py | Company directory phone assistant | LiveKit Docsnutritious-oyster-4341
08/26/2025, 7:58 PMnutritious-oyster-4341
08/26/2025, 7:59 PMtall-airline-16756
08/26/2025, 7:59 PMkind field:
◦ `STANDARD`: This is your original human participant (the end-user).
◦ `AGENT`: This represents the AI agent or any participant brought in by an agent.
• Transcription Segments: The transcription data includes a reference to the participant, so you can easily match each transcript to the right participant. You can filter transcripts by kind or identity to separate human and agent speech.
• Agent Components: If the AI agent uses an avatar worker to publish audio/video, you can check the lk.publish_on_behalf attribute to tell the main agent apart from its worker:
◦ Main agent: kind: AGENT and lk.publish_on_behalf is either missing or null.
◦ Avatar worker: kind: AGENT and lk.publish_on_behalf is set to the identity of the agent participant.
If you want, I’m here to help you set this up in your transcription workflow—just let me know!
Sources: Rooms, participants, and tracks | LiveKit Docs | Core API primitives | LiveKit Docs | Room & Participant Management | livekit/livekit_composite | DeepWiki | Virtual avatar integrations | LiveKit Docs | packages/react/src/hooks/useVoiceAssistant.tsnutritious-oyster-4341
08/26/2025, 10:16 PMtall-airline-16756
08/26/2025, 10:17 PMkind field of a participant in LiveKit by looking at the participant object in whichever SDK you're using. This kind field tells you what type of participant it is, like:
• `STANDARD`: A regular end-user participant.
• `AGENT`: An AI agent participant.
• `SIP`: A telephony participant connected via SIP.
• `INGRESS`: A participant ingesting streams.
• `EGRESS`: A participant consuming streams.
Here’s a quick rundown on how to grab it in different SDKs:
• Node.js: Just use the ParticipantInfo.kind field.
• Python: Access ParticipantInfo.kind from your participant object.
• Flutter: Use the kind getter on the Participant class.
• Swift: Check out Participant.kind as an enum with options like .standard, .agent, and so on.
• Unity: Use the Kind property on the Participant class.
For example, in Node.js, you might do something like this:
if (participant.kind === ParticipantKind.SIP) {
// Handle SIP-specific logic
}
If you want, just give me a shout for help with a specific SDK or if anything needs more explanation — I’m happy to help!
Sources: SIP participant | LiveKit Docs | Sources/LiveKit/Participant/Participant.swift | lib/src/context/participant_context.dart | livekit-rtc/livekit/rtc/_proto/participant_pb2.py | livekit/src/room/participant/mod.rsnutritious-oyster-4341
08/26/2025, 10:17 PMtall-airline-16756
08/26/2025, 10:18 PMkind field isn’t directly part of the ChatMessage object, but no worries—you can still figure out the participant type by checking out the related Participant object. Here’s a simple way to do it:
• Get the Participant: Every ChatMessage or transcription segment is linked to a participant. So, start by grabbing that participant object connected to your message.
• Look at the Participant Kind: Then, peek at the kind field on the participant to see what type it is:
◦ `STANDARD`: This means it’s a regular human participant.
◦ `AGENT`: This one’s an AI agent or bot.
Here’s how it looks in the LiveKit SDKs:
• Node.js: Check out ParticipantInfo.kind from the participant object.
• Python: Use Participant.kind to find the participant type.
• Flutter: Just look at kind on the Participant class.
If you want a hand setting this up in your workflow, just give me a shout—I’m happy to help!
Sources: livekit-rtc/livekit/rtc/participant.py | packages/livekit-rtc/src/proto/participant_pb.ts | lib/exts.dart | src/transcriptions/TranscriptionTile.tsx | Room & Participant Management | livekit/livekit_composite | DeepWiki