> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goguava.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# on_caller_dtmf()

> React to keypad presses from the caller

Register a handler that fires whenever the **caller** presses a DTMF digit (0–9, \*, #, A–D) on their keypad.

<Tabs>
  <Tab title="Python">
    <Note>
      **Caller keypresses only.** `on_caller_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, and register [`on_agent_dtmf`](/sdk-reference/on-agent-dtmf) to observe the digits it presses.
    </Note>

    <Info>
      **Previously `on_dtmf`:** this callback was named `on_dtmf` before `on_agent_dtmf` existed. The old name still registers the same handler and keeps working — it just no longer says which side of the call pressed the keys.
    </Info>

    The `DTMFPressedEvent` is a pydantic model imported from `guava.events`:

    ```python theme={null}
    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"]
        recent_digits: str = ''
    ```
  </Tab>

  <Tab title="TypeScript">
    <Note>
      **Caller keypresses only.** `onCallerDtmf` 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.setAgentDtmf(true)` instead, and register [`onAgentDtmf`](/sdk-reference/on-agent-dtmf) to observe the digits it presses.
    </Note>

    <Info>
      **Previously `onDtmf`:** this callback was named `onDtmf` before `onAgentDtmf` existed. The old name still registers the same handler and keeps working — it just no longer says which side of the call pressed the keys.
    </Info>

    The `DTMFPressedEvent` type is exported from `@guava-ai/guava-sdk`:

    ```typescript theme={null}
    import type { DTMFPressedEvent } from "@guava-ai/guava-sdk";

    type DTMFPressedEvent = {
      event_type: "dtmf";
      digit: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "*" | "#" | "A" | "B" | "C" | "D";
      recent_digits: string; // default: ""
    };
    ```
  </Tab>
</Tabs>

## Signature

<Tabs>
  <Tab title="Python">
    ```python signature theme={null}
    @agent.on_caller_dtmf
    def on_caller_dtmf(call: guava.Call, event: DTMFPressedEvent) -> None:
        ...
    ```

    | Parameter | Type | 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"; and `recent_digits` (string): the digits pressed so far in this run of keypresses, including this one. |

    **Return value:** `None`
  </Tab>

  <Tab title="TypeScript">
    ```typescript signature theme={null}
    agent.onCallerDtmf((call: guava.Call, event: DTMFPressedEvent) => Promise<void>);
    ```

    | Parameter | Type | 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"; and `recent_digits` (string): the digits pressed so far in this run of keypresses, including this one. |

    **Return value:** `Promise<void>`
  </Tab>
</Tabs>

## Example

<Tabs>
  <Tab title="Python">
    ```python controller.py theme={null}
    import logging

    from guava.events import DTMFPressedEvent

    @agent.on_caller_dtmf
    def on_caller_dtmf(call: guava.Call, event: DTMFPressedEvent):
        logging.info("Caller pressed %s (so far: %s)", event.digit, event.recent_digits)
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript controller.ts theme={null}
    import * as guava from "@guava-ai/guava-sdk";
    import type { DTMFPressedEvent } from "@guava-ai/guava-sdk";

    agent.onCallerDtmf(async (call: guava.Call, event: DTMFPressedEvent) => {
      console.log(`Caller pressed ${event.digit} (so far: ${event.recent_digits})`);
    });
    ```
  </Tab>
</Tabs>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.