red-insurance-72205
07/27/2025, 12:07 PMError transferring call: TwirpError(code=not_found, message=twirp error unknown: object cannot be found, status=404)
Full traceback:
File "/home/jaymataji/Documents/PersonalWork/RahulSharma/Neurality/sourcecodes/outbound-leadgen-agent/rp_outbound_agent.py", line 109, in transfer_call
response = await self.job_context.api.sip.create_sip_participant(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jaymataji/Documents/PersonalWork/RahulSharma/Neurality/sourcecodes/outbound-leadgen-agent/.venv/lib/python3.12/site-packages/livekit/api/sip_service.py", line 416, in create_sip_participant
return await self._client.request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jaymataji/Documents/PersonalWork/RahulSharma/Neurality/sourcecodes/outbound-leadgen-agent/.venv/lib/python3.12/site-packages/livekit/api/twirp_client.py", line 129, in request
raise TwirpError(
tall-airline-16756
07/27/2025, 12:07 PMtall-airline-16756
07/27/2025, 12:08 PMTwirpError(code=not_found, message=twirp error unknown: object cannot be found, status=404)
, typically indicates that a referenced object, such as a SIP trunk, cannot be found in your LiveKit project. Here are steps to resolve this issue:
1. Verify Your SIP Trunk Exists
• Check if your SIP trunk exists by listing your outbound trunks:
from livekit import api
livekit_api = api.LiveKitAPI(host, api_key, api_secret)
# List existing outbound trunks
trunks = await livekit_api.sip.list_sip_outbound_trunk(
api.ListSIPOutboundTrunkRequest()
)
print("Available SIP trunks:")
for trunk in trunks.items:
print(f"ID: {trunk.sip_trunk_id}, Name: {trunk.name}")
2. Create a SIP Trunk if None Exists
• If no SIP trunk exists, create one:
# Create an outbound SIP trunk
trunk = await livekit_api.sip.create_sip_outbound_trunk(
api.CreateSIPOutboundTrunkRequest(
trunk=api.SIPOutboundTrunkInfo(
name="My SIP Trunk",
address="<http://your-sip-provider.com|your-sip-provider.com>",
transport=api.SIPTransport.SIP_TRANSPORT_UDP,
numbers=["your-phone-number"],
auth_username="your-username",
auth_password="your-password",
)
)
)
print(f"Created trunk with ID: {trunk.sip_trunk_id}")
3. Use the Correct Trunk ID
• Ensure you are using the correct trunk ID in your request:
# Store the trunk ID (often from environment variables)
outbound_trunk_id = os.getenv("SIP_OUTBOUND_TRUNK_ID")
# Or get it from your created/listed trunks
outbound_trunk_id = trunk.sip_trunk_id
# Use it in the create participant request
await ctx.api.sip.create_sip_participant(
api.CreateSIPParticipantRequest(
room_name=ctx.room.name,
sip_trunk_id=outbound_trunk_id,
sip_call_to=phone_number,
participant_identity=participant_identity,
wait_until_answered=True,
)
)
4. Alternative: Use Direct SIP Configuration
• If you prefer, you can provide the SIP configuration directly instead of referencing a trunk ID:
await ctx.api.sip.create_sip_participant(
api.CreateSIPParticipantRequest(
trunk=api.SIPOutboundConfig(
hostname="<http://your-sip-provider.com|your-sip-provider.com>",
transport=api.SIPTransport.SIP_TRANSPORT_UDP,
auth_username="your-username",
auth_password="your-password",
),
room_name=ctx.room.name,
sip_call_to=phone_number,
participant_identity=participant_identity,
wait_until_answered=True,
)
)
5. Error Handling Best Practices
• Include proper error handling to get more details about the failure:
try:
participant = await ctx.api.sip.create_sip_participant(request)
print("call picked up successfully")
except api.TwirpError as e:
print(f"error creating SIP participant: {e.message}, "
f"SIP status: {e.metadata.get('sip_status_code')} "
f"{e.metadata.get('sip_status')}")
# Handle the error appropriately
ctx.shutdown()
Ensure that all referenced objects, particularly the SIP trunk, exist in your LiveKit project before attempting to create a SIP participant.
Sources: livekit-rtc/livekit/rtc/rpc.py | agent.py | Agents telephony integration | LiveKit Docsred-insurance-72205
07/27/2025, 1:48 PMtall-airline-16756
07/27/2025, 1:49 PM