is it possible to keep recording and get transcrip...
# ask-ai
n
is it possible to keep recording and get transcription after call transfer?
t
Thanks for reaching out, Hwuiwon. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Good news! You can keep recording and get transcription even after a call transfer in LiveKit, but there are a few things to keep in mind: • Recording: To make sure recording keeps going after a transfer, you’ll want to start egress recording separately from the agent’s session. This can be done using server-side APIs or room lifecycle hooks, so the recording doesn’t stop when the agent steps away. • Transcription: Transcription will pause if it’s linked only to the original agent since they’re no longer active after the transfer. To keep transcription going, another agent or service needs to take over the new call leg. If you’d like a hand setting up independent recording or transcription for transferred calls, just let me know—I’m here to help! Sources: Session recording and transcripts | LiveKit Docs | Transcriptions | LiveKit Docs | Transcriptions | LiveKit Docs | agent.py | sip-refer/agent.py
n
Is it possible to make another agent that will be silent and only work on the transcription and recording when the transfer happens? Or in other words, can transfer happen like the following?: user and initial agent is in the same room, when escalation happens, agent invites (calls the number that escalation will happen to), new agent that will handle transcription and recording joins along with the new human agent, and the original agent leaves.
t
Absolutely, you can create a silent agent that takes care of transcription and recording right after a call transfer. Here’s a simple way to think about it: • Recording: You can set up the silent agent to start recording using LiveKit's Egress feature. As long as the agent stays in the room, it can capture the entire session, including conversations between other participants after the transfer. • Transcription: The silent agent can also listen for speech events and save transcriptions without needing to actively speak—pretty handy, right? Here’s how it would work in your scenario: 1. The initial agent and user are chatting together in the room. 2. When it’s time to escalate, the initial agent invites the new human agent and the silent agent (for transcription and recording) into the room. 3. The initial agent then leaves, while the silent agent stays behind to keep recording and transcribing everything. This way, you keep everything running smoothly without missing a beat. If you want, I’m here to help you set it up! Sources: Session recording and transcripts | LiveKit Docs | Recording agent sessions | LiveKit Docs | Recording agent sessions | LiveKit Docs
n
Show me ways to set it up like actual code or e2e flow of how it should be handled
t
Here’s a complete flow and some handy code snippets to help you set up a silent agent for transcription and recording in LiveKit: 1. Bootstrap the Agent Start by using the LiveKit CLI or cloning a template to create a Python-based agent project:
Copy code
lk 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:
Copy code
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:
Copy code
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:
Copy code
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:
Copy code
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 Docs
n
what about the part where there's main agent, and making transfer & adding new transcription agent to the session?
t
Hey there! If you’re looking to handle call transfers and add a new transcription agent to your LiveKit session, here are some friendly approaches to get you started: 1. Adding a New Agent (Warm Transfer / Agent Handoff) Instead of going the SIP transfer route, you can hand off control to a new agent—like a transcription agent—while keeping the session alive. Here’s a simple example:
Copy code
@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:
Copy code
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 Docs
n
tell me more about the warm transfer
t
Warm transfer in LiveKit is a handy feature that lets an AI agent smoothly hand over a customer call to a human supervisor, making sure all the important context from the conversation is passed along. Here’s a quick rundown of how it works: Steps in Warm Transfer: 1. Customer requests escalation: The customer lets us know they’d like to chat with a human supervisor. 2. Agent places customer on hold: The AI agent gently mutes the customer’s audio and plays some hold music to keep things professional and comfortable. 3. Agent contacts the supervisor: A new room is created, and the agent uses the
CreateSIPParticipant
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 Docs
n
Is it possible to distinguish between the original human that ai agent was talking to vs the new human agent that got invited by ai agent?
This is for the transcript
t
Absolutely, you can tell apart the original human participant from the new human agent invited by the AI agent in LiveKit transcripts. Here’s a simple way to do it: • Participant Kind: Every participant in the room has a
kind
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.ts
n
how can i get the kind field?
t
Hey there! You can easily check out the
kind
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:
Copy code
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.rs
n
there's no kind field in ChatMessage. wdym
t
Just a quick heads-up: the
kind
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