await job_ctx.api.sip.transfer_sip_participant( ...
# ask-ai
e
await job_ctx.api.sip.transfer_sip_participant( api.TransferSIPParticipantRequest( room_name=job_ctx.room.name, participant_identity=sip_part.identity, # to use a sip destination, use
sip:user@host
format transfer_to=f"tel:{transfer_to}", ) ) can add dtmf code in livekit.
t
Thanks for reaching out, Shehryar. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Just a heads-up: you can’t add DTMF codes directly when transferring a SIP participant using the
TransferSIPParticipant
API. But no worries! You can send DTMF tones right after the transfer starts by using the
publishDtmf
method from a participant in the room. Here’s a quick example of how to send those DTMF tones after the transfer:
Copy code
await local_participant.publish_dtmf(code=1, digit='5')  # Press '5' for IVR
await asyncio.sleep(1)
await local_participant.publish_dtmf(code=11, digit='#')  # End input with '#'
If you want a hand setting this up or have any questions, just give me a shout! Sources: lib/livekit/sip_service_client.rb | Company directory phone assistant | LiveKit Docs | rpc/sip.pb.go | livekit-protocol/src/livekit.rs | Handling DTMF | LiveKit Docs
e
but the session ended when participant become active in cold transfer.
t
Hey there! In LiveKit, a cold transfer actually ends the session because it’s set up to move the SIP participant to a different endpoint without keeping the original session going. This is totally on purpose—once the transfer is done, the current room (or session) closes to make sure everything runs smoothly and resources are managed properly. If you want to keep the session alive, you might want to try a warm transfer instead. That way, the original session stays active while the transfer happens. Just let me know if you want me to walk you through it or help you explore other options—I’m here to help! Sources: Agents telephony integration | LiveKit Docs | Transferring calls | LiveKit Docs
e
i want a cold transfer with dtmf
t
Here’s how you can perform a cold transfer with DTMF in LiveKit, step by step: 1. Set Up DTMF Handling: Keep an ear out for DTMF signals in the room by using the
sip_dtmf_received
event. Then, match the digits you get to the transfer destination you want. 2. Initiate Cold Transfer: Go ahead and use the
TransferSIPParticipant
API to move the SIP participant over to the new spot. This will wrap up the current session since it’s a cold transfer. 3. Provide Feedback: If you like, you can let the caller know what’s happening by using speech synthesis before you kick off the transfer. 4. Configure SIP Trunk: Make sure your SIP trunk is ready to handle transfers. For instance, with Twilio, you’d want to turn on transfer mode and set up caller ID properly. If you’d like some detailed code examples or need a hand with this, just give me a shout—I’m here to help! Sources: Transferring calls | LiveKit Docs | livekit-agents/livekit/agents/job.py | Handling DTMF | LiveKit Docs | ivr-nagivator/agent.py | Company directory phone assistant | LiveKit Docs
e
i need to send dtmf to cold transfer participant not to recieve a dtmf. i need to send dtmf before the session closed in cold transfer.
t
Hey there! To send DTMF to the cold transfer participant before the session closes, here’s a simple way to do it: 1. Send DTMF Signals: You can use the
publish_dtmf
method to send the DTMF tones you need. For example:
Copy code
await room.local_participant.publish_dtmf(code=1, digit='1')
await room.local_participant.publish_dtmf(code=2, digit='2')
await room.local_participant.publish_dtmf(code=3, digit='3')
await room.local_participant.publish_dtmf(code=11, digit='#')
1. Timing: It’s a good idea to add a short delay (1-2 seconds) after sending the DTMF signals. This helps make sure they’re properly processed before you start the transfer. 2. Initiate Cold Transfer: Once the DTMF tones are sent, use the
TransferSIPParticipant
API to perform the transfer like this:
Copy code
transfer_request = TransferSIPParticipantRequest(
    participant_identity=participant_identity,
    room_name=room_name,
    transfer_to=transfer_number,
    play_dialtone=True
)
await livekit_api.sip.transfer_sip_participant(transfer_request)
This way, the DTMF tones reach the participant before the session closes. If you have any questions or need a hand with anything else, just let me know—I’m here to help! Sources: complex-agents/ivr-agent/agent.py | Company directory phone assistant | LiveKit Docs | livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Local... | src/room/participant/LocalParticipant.ts | packages/livekit-rtc/src/proto/room_pb.ts
e
dtmf = "wwwwwwww200# to this extenion
t
If you want to send a DTMF sequence with pauses, like
wwwwwwww200#
, in LiveKit, you can use the
publish_dtmf
method and add some delays between each tone to create those pauses. Each 'w' stands for a pause, which you can easily handle with a delay (for example, using
asyncio.sleep()
in Python). Here’s a simple example to get you started:
Copy code
# Sending '200#' with pauses represented by 'w'
import asyncio

# Simulate 'wwwwwwww' (8 pauses)
for _ in range(8):
    await asyncio.sleep(0.5)  # Feel free to tweak the pause length to what works best for you

# Now send '200#'
await room.local_participant.publish_dtmf(code=2, digit='2')
await asyncio.sleep(0.5)
await room.local_participant.publish_dtmf(code=0, digit='0')
await asyncio.sleep(0.5)
await room.local_participant.publish_dtmf(code=0, digit='0')
await asyncio.sleep(0.5)
await room.local_participant.publish_dtmf(code=11, digit='#')
Feel free to adjust the pause durations and timing between tones to fit your needs. If you have any questions or want me to walk you through it, just let me know—I’m here to help!