sip
sip copied to clipboard
Could you explain the monitoring dialing status example?
In this example, when call_status == "active" it immediately returns from (supposedly entrypoint) function, but in my understanding, the call_status should transition like "dialing" → "active" → "hangup". So if you implement like this, it never enters the call_status == "hangup" branch. Could you correct my understanding? Thanks.
start_time = perf_counter()
while perf_counter() - start_time < 30:
call_status = participant.attributes.get("sip.callStatus")
if call_status == "active":
logger.info("user has picked up")
return
elif call_status == "automation":
# if DTMF is used in the `sip_call_to` number, typically used to dial
# an extension or enter a PIN.
# during DTMF dialing, the participant will be in the "automation" state
pass
elif call_status == "hangup":
# user hung up, we'll exit the job
logger.info("user hung up, exiting job")
break
await asyncio.sleep(0.1)
logger.info("session timed out, exiting job")
ctx.shutdown()
https://docs.livekit.io/agents/quickstarts/outbound-calls/#monitoring-dialing-status
I think you are right, we should fix this example code.