big-controller-60015
05/12/2025, 1:36 PMtall-airline-16756
05/12/2025, 1:36 PMtall-airline-16756
05/12/2025, 1:36 PMsetup_dtmf_handlers
function to register handlers for DTMF events in the room.
2. Register a handler for the "sip_dtmf_received" event: This event is triggered when a DTMF tone is received. For example: @room.on("sip_dtmf_received")
def handle_dtmf(dtmf_event: rtc.SipDTMF):
asyncio.create_task(_async_handle_dtmf(dtmf_event))
3. Process DTMF events: In the handler, you can access the DTMF code, digit, and participant identity to perform actions such as interrupting the agent or transferring calls. For example: async def _async_handle_dtmf(dtmf_event: rtc.SipDTMF):
await phone_assistant.session.interrupt()
<http://logger.info|logger.info>("Interrupted agent due to DTMF")
code = dtmf_event.code
digit = dtmf_event.digit
identity = dtmf_event.participant.identity
# Map digits to departments and handle transfers
department_numbers = {
"1": ("BILLING_PHONE_NUMBER", "Billing"),
"2": ("TECH_SUPPORT_PHONE_NUMBER", "Tech Support"),
"3": ("CUSTOMER_SERVICE_PHONE_NUMBER", "Customer Service")
}
if digit in department_numbers:
# Handle transfer logic
else:
# Handle invalid input
This setup allows callers to press buttons on their phone keypad to interact with the agent, such as selecting departments for call transfers.
Sources: Company directory phone assistant | LiveKit Docs | livekit.rtc.room API documentation