having issues with transfer
# ask-ai
c
having issues with transfer
t
Thanks for reaching out, Joshua. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m here to help with the transfer issue. To diagnose quickly, could you clarify which kind of "transfer" you mean: • SIP/PSTN call transfer (cold/REFER or warm/agent-assisted), or • transferring participants/tracks between rooms or users, or • something else? Also please provide: • LiveKit SDK & exact version (JS, iOS, Android, server), • short reproduction steps (what you do and what happens), • any error messages or logs (exact text), • whether you use hosted LiveKit or self-hosted. Send those details and I’ll suggest the next troubleshooting steps. Sources: Agent-assisted warm transfer | LiveKit docs | Call forwarding | LiveKit docs | SIP troubleshooting guide | LiveKit docs | Using Wavix to accept and make calls | LiveKit docs
Thanks — I reviewed your logs and code. You're getting the CreateSIPParticipant failure then a successful fallback transfer. That means the attempt to place a new outbound call (CreateSIPParticipant) is failing, but the fallback cold transfer (TransferSIPParticipant) succeeds. What I recommend next (short checklist and minimal code guidance): 1. Confirm your intent • Do you want to (A) add a human into the room (warm/consultative transfer) or (B) transfer the current inbound caller directly to a phone number (cold transfer)? ◦ If B, skip CreateSIPParticipant entirely and call TransferSIPParticipant directly. Your logs show TransferSIPParticipant already succeeds. 1. If you intend warm transfer (invite human into room) • Verify the trunk supports outbound calls and the
sip_trunk_id
is an outbound-capable trunk. • Ensure the access token used has the SIP
call
grant. • Use
wait_until_answered=True
(you already do) and handle errors from create call; if create fails, inspect the exception text for trunk/provider errors. • Validate
participant_identity
format (you sanitize — keep E.164 for
sip_call_to
and sanitized identity for
participant_identity
). 1. If you intend cold transfer (transfer caller) • Replace the CreateSIPParticipant flow with a TransferSIPParticipantRequest using the inbound participant identity (the one you see in logs, e.g.,
sip_18574204454_outbound
) and
transfer_to="tel:+18574204454"
. Example flow:
Copy code
transfer_request = TransferSIPParticipantRequest(
  room_name=self.ctx.room.name,
  participant_identity=participant_identity,   # inbound caller identity
  transfer_to=f"tel:{selected_number}",
  play_dialtone=True
)
await lkapi.sip.transfer_sip_participant(transfer_request)
1. Quick checks to run now • Confirm
ST_6zVEuhLbud9m
is listed as an outbound trunk. • Confirm provider allows SIP REFER / PSTN transfer. • Check exact exception message from
invite_error
(log the full exception) to pinpoint why CreateSIPParticipant failed (trunk/permission/format). If you tell me whether you want warm vs cold transfer and paste the full exception text from the CreateSIPParticipant failure, I’ll give the exact code change and checks to resolve it. Sources: Make outbound calls | LiveKit docs | Call forwarding | LiveKit docs | SIP APIs | LiveKit docs | sip | livekit/livekit_composite | DeepWiki | Agent-assisted warm transfer | LiveKit docs
c
I have bothb ut iwant to implement the warm one cold call forwarding is the fallback to this exceptoion
t
Thanks — since you want the warm (agent-assisted) flow, here’s what to do and what to check so CreateSIPParticipant succeeds instead of falling back to a cold transfer. What to implement (warm transfer workflow) 1. Put the caller on hold (mute caller audio) so they’re not hearing the consultation. 2. Create a separate consultation room and connect a transfer-agent identity there. 3. Use CreateSIPParticipant to call the supervisor into the consultation room. 4. After supervisor answers, move the supervisor into the caller’s room (use MoveParticipant). 5. Once the supervisor and caller are bridged, remove the transfer agent and resume audio for the caller. Key fixes / checks so CreateSIPParticipant does not fail • Ensure the token used to call CreateSIPParticipant includes the SIP
call
grant:
Copy code
{
  "sip": {
    "call": true
  }
}
• Verify
sip_trunk_id
is an outbound-capable trunk (not inbound-only) and the provider credentials/address are correct (use provider root address, e.g.,
sip.telnyx.com
). • Confirm the trunk/provider allows outbound dialing and SIP REFER/PSTN transfer if needed. • Use E.164 for
sip_call_to
(e.g.,
+18574204454
) and a sanitized identity for
participant_identity
. • If you use
wait_until_answered=True
, be aware of timeouts; try
wait_until_answered=False
during testing and handle the answered event asynchronously. • Log and inspect the full exception from CreateSIPParticipant (the stack/HTTP status or provider error) to identify if it’s a trunk auth, DNS/address, or timeout issue. Implementation notes and LiveKit specifics • Warm transfer requires a consult room +
MoveParticipant
to bring the supervisor into the caller’s room.
MoveParticipant
is a LiveKit Cloud feature (not available on some self-hosted setups). • Use CreateSIPParticipant only to dial the supervisor into the consultation room (then MoveParticipant). Do not rely on creating an outbound participant in the caller room if your intent is an agent-assisted consult. • If CreateSIPParticipant continues to fail after the checks above, capture and paste the full exception text (HTTP status, provider error details) and I’ll point to the exact trunk or token fix. If you want, paste: • the full exception/stack trace from the CreateSIPParticipant failure, and • whether you’re on LiveKit Cloud or self-hosted, and your trunk id (confirm outbound capability) I’ll give the exact code and config changes next. Sources: SIP APIs | LiveKit docs | Authentication | LiveKit docs | SIP troubleshooting guide | LiveKit docs | Agent-assisted warm transfer | LiveKit docs | Make outbound calls | LiveKit docs
c
on twilio the trunk needs to be on termination or originatino?
t
Use both: • Origination for inbound calls (so Twilio routes incoming PSTN calls to your LiveKit SIP URI). • Termination for outbound calls/transfers (required so Twilio can place outbound legs or honor SIP REFER); ensure a Credential List (auth) is configured for termination. Also enable Twilio's "Call Transfer (SIP REFER) / PSTN Transfer" in the trunk settings so transfers succeed. Sources: Create and configure a Twilio SIP trunk | LiveKit docs | Call forwarding | LiveKit docs
Thanks — I see two separate problems in your latest logs: (A) CreateSIPParticipant is still failing (then your code correctly falls back to TransferSIPParticipant), and (B) a Python TypeError from
await self.ctx.room.sid
(AsyncMock). I'll address both and give precise next steps. 1) CreateSIPParticipant still failing — targeted checks • Log the full exception from the
invite_error
(HTTP status / provider error). That exact text shows whether it’s trunk auth, DNS/address, or timeout. Please paste it. • Confirm these three items for your Twilio trunk: ◦ Termination (outbound) configured with a Credential List (username/password) for LiveKit to authenticate when placing outbound calls. ◦ Call Transfer (SIP REFER / PSTN Transfer) enabled in the Twilio trunk settings. ◦ Origination configured so inbound calls reach LiveKit (you said this is enabled). • Verify the token you use to call
create_sip_participant
contains the SIP
call
grant:
Copy code
{
  "sip": {
    "call": true
  }
}
• Try switching
wait_until_answered=True
→
False
while testing to rule out answer-timeout issues. If this makes it succeed, your problem was a timeout while waiting for the supervisor to pick up. • Ensure
sip_trunk_id
is the correct outbound trunk id and
sip_call_to
is E.164 (
+18574204454
). Keep
participant_identity
sanitized as you are doing. • Enable verbose debug/logging on the Twilio trunk side (or check Twilio call logs) to see if Twilio rejects the outbound leg (401 auth, 403, or 404). 2) TypeError: AsyncMock can't be used in 'await' expression • The traceback shows
doc_id=await self.ctx.room.sid
—
self.ctx.room.sid
is an AsyncMock (test/mocking object) rather than an awaitable/sync value. Fix by: ◦ If
room.sid
is synchronous/string: remove
await
and use
doc_id = self.ctx.room.sid
. ◦ If
room.sid
is a coroutine: await the coroutine (e.g.,
doc_id = await self.ctx.room.sid()
). • Search your code for other uses of
await
on attributes that are simple values and remove
await
there. 3) Minimal repro and immediate actions I can help with • Please paste: ◦ the full exception text from the CreateSIPParticipant failure (the contents of
invite_error
). ◦ whether you’re using LiveKit Cloud or self-hosted (MoveParticipant availability matters). ◦ the lines around where you access
self.ctx.room.sid
(so I can suggest exact code fix). • While you fetch that, try: ◦ logging the invite exception, ◦ testing CreateSIPParticipant with
wait_until_answered=False
, ◦ and changing
doc_id=await self.ctx.room.sid
→
doc_id=self.ctx.room.sid
(if sid is not async). If you share the full CreateSIPParticipant exception and the small code snippet around
self.ctx.room.sid
, I’ll give the exact code edits and the likely trunk/token fix.
Thanks — I see your CreateSIPParticipant call code. To get this to succeed for a warm transfer, please check/try the following precise items and share any failures or logs you see: 1) Token grant • Confirm the token used for the API call includes the SIP
call
grant:
Copy code
{
  "sip": {
    "call": true
  }
}
2) Trunk termination/auth • Ensure
ST_6zVEuhLbud9m
is configured for termination (outbound) with a Credential List (username/password) so Twilio accepts outbound legs from LiveKit. • Confirm the trunk appears in Twilio’s outbound/termination list and that credentials are valid. 3) sip_call_to & identity format • Use E.164 for
sip_call_to
(e.g.,
+18574204454
) and sanitized ASCII for
participant_identity
(you already sanitize — keep that). • Set
sip_call_to= "+18574204454"
(not
tel:+...
) when passing to CreateSIPParticipant if your SDK expects plain E.164; if it expects
tel:
, use
tel:+1857...
— check which your LiveKit SDK variant expects. 4) wait_until_answered • For debugging, set
wait_until_answered=False
to avoid timeouts. If this makes the call succeed, the failure was an answer timeout. Then you can handle answer events instead. 5) Inspect and paste the full invite exception • In your except block, log the full exception including HTTP status/body:
Copy code
except Exception as invite_error:
    logger.exception("CreateSIPParticipantRequest failed")
• Paste that full logged traceback/HTTP body here — it will show if Twilio returned 401/403/404 or a timeout. 6) Twilio-side debug • Check Twilio trunk call logs for the attempted outbound leg at the same timestamp — Twilio will show if it rejected the request (auth/DNS/403/etc.) or if it never received it. 7) Quick runtime checks • Confirm you’re calling
participant = await lkapi.sip.create_sip_participant(invite_request)
with the API client authenticated by a token that has SIP grants and not a mocked/test token. • Ensure DNS for your configured trunk address is reachable from your LiveKit server. If you run the request with
wait_until_answered=False
and then paste the full exception/traceback you get when it still fails (or the Twilio call-log error code), I’ll pinpoint the exact fix.
c
----------------------------------------------- 2025-12-06 191124,412 - INFO RootAgent - calling from firebase 2025-12-06 191127,209 - ERROR RootAgent - CreateSIPParticipantRequest failed (identity); falling back to TransferSIPParticipantRequest
t
Thanks — I see CreateSIPParticipant still fails and falls back. To diagnose the root cause I need one more thing: please paste the full exception/traceback that was logged for the CreateSIPParticipant failure (the full text from your except block — HTTP status/body or provider error). While you fetch that, please confirm these three quick facts: • Are you on LiveKit Cloud or self-hosted? • The exact value/form you send in
sip_call_to
(e.g.,
+18574204454
or
tel:+18574204454
)? • Does the API client used for
create_sip_participant
use an access token that includes
"sip": {"call": true}
? With the full exception and these confirmations I’ll pinpoint whether it’s a trunk auth/DNS/timeout issue or a request-format/token problem and give the exact code/config change.
c
where and how do i add sip calll as true
t
Add the SIP
call
grant when you generate the LiveKit access token on your backend. Examples: Python (server):
Copy code
from livekit import api

token = (
  api.AccessToken(api_key="API_KEY", api_secret="API_SECRET")
  .with_identity("transfer-agent")
  .with_grants(api.VideoGrants(room_join=True, room="my-room"))
  .with_sip_grants(api.SIPGrants(admin=False, call=True))  # <-- call=True here
  .to_jwt()
)
Node.js:
Copy code
import { AccessToken, SIPGrant, VideoGrant } from "livekit-server-sdk";

const at = new AccessToken("apiKey", "secret", { identity: "transfer-agent" });
at.addGrant({ roomJoin: true, room: "my-room" }); // video grant
at.addGrant(new SIPGrant({ admin: false, call: true })); // <-- call: true
const jwt = at.toJwt();
Go:
Copy code
at := auth.NewAccessToken("apiKey","secret")
at.SetIdentity("transfer-agent").
   SetVideoGrant(&auth.VideoGrant{RoomJoin:true, Room:"my-room"}).
   SetSIPGrant(&auth.SIPGrant{Admin:false, Call:true}) // <-- Call:true
token, _ := at.ToJWT()
Key points: • Generate the token server-side (never in client code). • The
sip.call = true
grant must be present for CreateSIPParticipant to allow outbound calls. • Use that token when calling
create_sip_participant
. • After adding the grant, if CreateSIPParticipant still fails, paste the full exception/log (HTTP status and body) and I’ll help diagnose further. Sources: Authentication | LiveKit docs | sip | livekit/livekit_composite | DeepWiki
c
2025-12-06 193911,579 - INFO RootAgent - 🆔 STEP 8: Creating participant identity: sip_18574204454_transfer 2025-12-06 193911,579 - INFO RootAgent - 🏢 STEP 9: Room name: mock_room 2025-12-06 193911,579 - INFO RootAgent - 📡 STEP 10: SIP trunk ID: ST_6zVEuhLbud9m 2025-12-06 193911,579 - INFO RootAgent - 📤 STEP 11: Sending CreateSIPParticipantRequest with identity: sip_18574204454_transfer 2025-12-06 193913,668 - ERROR RootAgent - ❌ STEP 12 FAILED: CreateSIPParticipantRequest failed with error: AttributeError: identity
t
Thanks — the error shows CreateSIPParticipant failed with an AttributeError: identity. That indicates the request object you're building uses the wrong field name. CreateSIPParticipantRequest expects
participant_identity
(or
participantIdentity
depending on SDK), not
identity
. What to change (Python example)
Copy code
from livekit import api

invite_req = api.CreateSIPParticipantRequest(
  sip_trunk_id="ST_6zVEuhLbud9m",
  sip_call_to="+18574204454",
  room_name="mock_room",
  participant_identity="sip_18574204454_transfer",  # <-- correct key
  wait_until_answered=True,
)
await lkapi.sip.create_sip_participant(invite_req)
Quick checklist to verify after fixing the field • Token includes
sip.call = true
(server-side token). •
sip_trunk_id
is outbound-capable and valid. •
sip_call_to
is E.164 (
+18574204454
) or uses
tel:
only if your SDK requires it. • Log the full exception if it still fails (use
logger.exception(...)
) so I can see HTTP status/body. If you paste the snippet where you build the CreateSIPParticipantRequest (or the full traceback after switching the field), I’ll point out the exact line to change.