how to get the phone number of inbound call in liv...
# ask-ai
n
how to get the phone number of inbound call in livekit agents?
t
Thanks for reaching out, Tareq. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To retrieve the phone number of an inbound call in LiveKit Agents, you can use the
sip.phoneNumber
attribute of the SIP participant. Here are the key points to consider: • The phone number is available in the
sip.phoneNumber
attribute for SIP participants. • You can identify SIP participants using
Participant.Kind == SIP
. • Ensure that the
HidePhoneNumber
setting is not enabled in the dispatch rule, as this would prevent the phone number from being available. If you need further assistance with implementation details or accessing these attributes programmatically, let me know! Sources: SIP participant | LiveKit Docs
n
how to access the sip participant in livekit agents job
t
• *Using
wait_for_participant
with SIP kind filtering:*`from livekit import rtc async def entrypoint(ctx: JobContext): # Wait specifically for a SIP participant participant = await ctx.wait_for_participant( kind=rtc.ParticipantKind.PARTICIPANT_KIND_SIP )` • *Filtering existing participants:*`# Get all SIP participants in the room sip_participants = [ p for p in ctx.room.remote_participants.values() if p.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP ] # Get the first SIP participant if sip_participants: sip_participant = sip_participants[0]` • *Handling participant connection events:*`async def entrypoint(ctx: JobContext): def on_participant_connected_handler(participant: rtc.RemoteParticipant): asyncio.create_task(async_on_participant_connected(participant)) async def async_on_participant_connected(participant: rtc.RemoteParticipant): # Check if this is a SIP participant if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP: logger.info(f"SIP participant connected: {participant.identity}") # Access SIP-specific attributes if participant.attributes: call_id = participant.attributes.get('sip.callID', 'Unknown') phone_number = participant.attributes.get('sip.phoneNumber', 'Unknown') ctx.room.on("participant_connected", on_participant_connected_handler)` Hey there! I wanted to walk you through some friendly ways to work with SIP participants in LiveKit Agents. These methods should help you easily track and interact with SIP connections. Once you've got the SIP participant, you'll be able to grab cool details like their phone number or call ID through the handy attributes field. Pretty neat, right? Need me to break any of this down further? I'm totally here to help you make sense of it all! 😊 Just give me a shout if something isn't crystal clear. Sources: examples/src/outbound.ts | telephony/sip_lifecycle.py | SIP participant | LiveKit Docs | SIP participant | LiveKit Docs | examples/voice_agents/error_callback.py