Handling DTMF

Sending and receiving DTMF tones.

LiveKit's Telephony stack fully supports DTMF tones, enabling integration with legacy IVR systems. It also enables agents to receive DTMF tones from telephone users.

Sending DTMF

To send DTMF tones, use the publishDtmf API on the localParticipant.

This API transmits DTMF tones to the room; tones can be sent by any participant in the room.

SIP participants in the room receive the tones and relay them to the telephone user.

// publishes 123# in DTMF
await localParticipant.publishDtmf(1, '1');
await localParticipant.publishDtmf(2, '2');
await localParticipant.publishDtmf(3, '3');
await localParticipant.publishDtmf(11, '#');
Tip

Sending DTMF tones requires both a numeric code and a string representation to ensure compatibility with various SIP implementations.

Special characters like * and # are mapped to their respective numeric codes. See RFC 4733 for details.

Receiving DTMF

When SIP receives DTMF tones, they are relayed to the room as events that participants can listen for.

room.on(RoomEvent.DtmfReceived, (code, digit, participant) => {
console.log('DTMF received from participant', participant.identity, code, digit);
});