Skip to main content

Overview

DTMFAggregator processes incoming DTMF (Dual-Tone Multi-Frequency) frames from phone keypad input and aggregates them into complete sequences that can be understood by LLM services. It buffers individual digit presses and flushes them as transcription frames when a termination digit is pressed, a timeout occurs, or an interruption happens. This aggregator is essential for telephony applications where users interact via phone keypad buttons, converting raw DTMF input into structured text that LLMs can process alongside voice transcriptions.

Constructor

timeout
float
default:"2.0"
Idle timeout in seconds before flushing the aggregated digits
termination_digit
KeypadEntry
default:"KeypadEntry.POUND"
Digit that triggers immediate flush of the aggregation
prefix
str
default:"DTMF: "
Prefix added to DTMF sequence in the output transcription

Input Frames

InputDTMFFrame
Frame
Contains a single keypad button press with a KeypadEntry value
EndFrame
Frame
Flushes pending aggregation and stops the aggregation task

Output Frames

TranscriptionFrame
Frame
Contains the aggregated DTMF sequence as text with the configured prefix
All input frames are passed through downstream, including the original InputDTMFFrame instances.

Keypad Entries

The aggregator processes these standard phone keypad entries:

Aggregation Behavior

The aggregator flushes (emits a TranscriptionFrame) when:
  1. Termination digit: The configured termination digit is pressed (default: #)
  2. Timeout: No new digits received within the timeout period (default: 2 seconds)
  3. Interruption: A InterruptionFrame is received
  4. Pipeline end: An EndFrame is received

Usage Examples

Basic Telephony Integration

Custom Configuration for Menu Systems

Sequence Examples

Frame Flow

Error Handling

The aggregator gracefully handles:
  • Invalid DTMF digits (logged and ignored)
  • Pipeline interruptions (flushes pending sequences)
  • Rapid key presses (buffers efficiently)
  • Mixed voice and DTMF input (processes independently)

Best Practices

  1. System Prompt Design: Train your LLM to recognize and respond to DTMF prefixed input
  2. Timeout Configuration: Use shorter timeouts (1-2s) for rapid entry, longer (3-5s) for menu selection
  3. Termination Strategy: Use # for confirmation, * for cancel/back operations
  4. Pipeline Placement: Always place before the user context aggregator to ensure proper frame ordering