I am getting the following error while trying the ...
# ask-ai
r
I am getting the following error while trying the python sdk function to create sip participant. It was working previously as expected.
Copy code
Error 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(
t
Thanks for reaching out, Rajendra. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The error you're encountering,
TwirpError(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:
Copy code
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:
Copy code
# 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:
Copy code
# 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:
Copy code
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:
Copy code
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 Docs
r
I have a setup in which the user is in the room and now i am transferring the call to human agent. Is it possible in livekit to just talk to human agent first without the user listening to that?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!