proud-lawyer-39815
10/13/2025, 6:36 PMtall-airline-16756
10/13/2025, 6:36 PMtall-airline-16756
10/13/2025, 6:37 PMsip_dtmf_received event, which gets triggered whenever a SIP participant sends DTMF tones, like when they press keys on their phone keypad.
Here’s a simple way to get you started:
1. Set up an event listener on the rtc.Room object for the sip_dtmf_received event. This event will give you useful info about the digit pressed, who sent it, and the numeric DTMF code.
2. Make sure your agent connects to the LiveKit room with audio enabled. Using AutoSubscribe.AUDIO_ONLY helps automatically receive audio from participants.
3. Then, you can define your own logic to handle the detected DTMF tones—maybe routing calls or triggering actions based on what input you get.
Here’s a quick example in Python to illustrate:
@room.on("sip_dtmf_received")
def handle_dtmf(dtmf_event):
digit = dtmf_event.digit
identity = dtmf_event.participant.identity
print(f"DTMF received: {digit} from {identity}")
If you’d like, I’m happy to walk you through any part of this or help with more specific implementation details. Just let me know!
Sources: ivr-nagivator/agent.py | livekit-rtc/livekit/rtc/room.py | Company directory phone assistant | LiveKit Docs | agent.pyproud-lawyer-39815
10/13/2025, 6:51 PMtall-airline-16756
10/13/2025, 6:52 PMJobContext gives you a handy room property for direct access. For example, in Python:
from livekit.agents import JobContext
async def entrypoint(ctx: JobContext):
room = ctx.room
await session.start(agent=agent, room=ctx.room)
• From Event Callbacks: You can also grab the current job context inside event callbacks to get the room. Here's how:
@ctx.room.local_participant.register_rpc_method("start_turn")
async def start_turn(data):
job_ctx = get_job_context()
room = job_ctx.room
• From Agent Sessions: When you start an agent session, you usually pass the room as a parameter like this:
await session.start(agent=MyAgent(), room=ctx.room)
If any part of this feels unclear or if you'd like more examples, please don’t hesitate to ask—I’m here to help!
Sources: examples/voice_agents/push_to_talk.py | agents/src/job.ts | events/basic_event.py