wide-dress-57902
08/12/2025, 12:24 AMtall-airline-16756
08/12/2025, 12:24 AMtall-airline-16756
08/12/2025, 12:24 AMsip.callStatus
attribute of the participant. Here’s a friendly step-by-step on how to do this:
1. Create the SIP Participant: Use the create_sip_participant
method to kick off the call. This will start dialing the user and return right away.
2. Watch the Call Status: After you create the participant, keep checking the sip.callStatus
attribute. It’ll switch to active
once the call is answered.
3. Let the Agent Speak: As soon as the call status hits active
, use the agent's generate_reply
method to get the conversation going.
Here’s a handy Python snippet to guide you:
import asyncio
async def monitor_call_status(participant):
start_time = asyncio.get_event_loop().time()
while asyncio.get_event_loop().time() - start_time < 30:
call_status = participant.attributes.get("sip.callStatus")
if call_status == "active":
print("Call is active, agent will start speaking.")
await session.generate_reply(
instructions="Greet the user and offer your assistance."
)
return
elif call_status == "hangup":
print("Call has been ended.")
break
await asyncio.sleep(0.1)
print("Call monitoring timed out.")
This way, your agent will jump in right after the call connects. If you have any questions or need a hand with this, just let me know—I’m here to help!
Sources: agents/src/pipeline/pipeline_agent.ts | Make outbound calls | LiveKit Docs | Making calls using SIP | LiveKit Docs | Making calls using SIP | LiveKit Docs | Agents telephony integration | LiveKit Docs