on_dtmf()
Register a handler that fires whenever the caller presses a DTMF digit (0–9, *, #, A–D) on their keypad.
Caller keypresses only. on_dtmf fires for digits pressed by the caller. To enable the agent itself to send DTMF tones (e.g. to navigate an IVR system it has called into), use call.set_agent_dtmf(enabled=True) instead.
The DTMFPressedEvent is a pydantic model imported from guava.events:
from guava.events import DTMFPressedEvent
class DTMFPressedEvent(BaseEvent):
event_type: Literal["dtmf"] = "dtmf"
digit: Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "#", "A", "B", "C", "D"]Signature
signature
@agent.on_dtmf
def on_dtmf(call: guava.Call, event: DTMFPressedEvent) -> None:
...| Parameter | Type | Default | Description |
|---|---|---|---|
| call | Call | — | The active call object. |
| event | DTMFPressedEvent | — | Contains `digit` (string): the key the caller pressed — one of "0"–"9", "*", "#", "A", "B", "C", or "D". |
Return value: None
Questions? hi@goguava.ai
from guava.events import DTMFPressedEvent
class DTMFPressedEvent(BaseEvent):
event_type: Literal["dtmf"] = "dtmf"
digit: Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "#", "A", "B", "C", "D"]