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

# Keypad input (DTMF) in flow agents

> Let callers press keys to choose a path, or type digits such as an account number or PIN into a variable, and see how key presses are handled on a call.

Callers can use their phone's keypad in a flow agent in two ways: press one key to choose a path ("press 1 for sales"), or type a series of digits, such as an account number, that the agent saves in a variable. Both are set up on Conversation steps and on the Start step in conversation mode. This page shows how, and what happens on a call.

## Route the call with a key

Add a **DTMF input** transition for each key the caller can press.

**1. Add the transition**

On a Conversation step card (or the Start step in conversation mode), click **Add** and choose **DTMF input** ("Keypad input detection").

**2. Pick the key**

Click the transition on the card. Its settings open in the step's settings panel. Under **Keypad key** ("The call takes this path when the caller presses the key."), pick 0 to 9, \* or #. The key is saved as you pick it, and the transition reads "Press 1" (for key 1).

**3. Connect it**

Drag from the transition's handle to the step that key leads to.

**4. Tell the caller**

Say the options in the step's message, for example "Press 1 for sales or 2 for support. You can also just tell me what you need."

Key transitions sit next to the step's other transitions. A caller who speaks instead of pressing a key is handled by the step's **Prompt** transitions as usual.

## Capture digits into a variable

Use this for numbers the caller types, such as an account number or a PIN. The digits are saved when the caller presses a finishing key, `#` or `*`.

**1. Add DTMF capture to the step**

On a Conversation step (or the Start step in conversation mode), open **Variables**, click **Add variable** and choose **DTMF capture**.

**2. Name the variable**

Enter a **Variable name** in snake\_case, for example `account_number`. The field is required.

**3. Add the finishing key**

Add a **DTMF input** transition with `#` (or `*`) and connect it to the step that uses the number. Without it, the digits are never saved.

![The Keypad key setting of a DTMF input transition with # selected, and the note that only \* and # are available while DTMF capture is on](https://mintcdn.com/hamsa-452fa79a/Rl78D_qJIpinmg19/images/agents/flow/keypad-key-picker-light.webp?fit=max\&auto=format\&n=Rl78D_qJIpinmg19\&q=85\&s=160aea711bb59b0ad96d499b1556a23c)

**4. Tell the caller how to finish**

For example: "Please type your account number, then press the hash key."

![An Account number step with DTMF capture into account\_number in its Variables section, and a Press # transition connected to the Look up order step](https://mintcdn.com/hamsa-452fa79a/Rl78D_qJIpinmg19/images/agents/flow/keypad-capture-step-light.webp?fit=max\&auto=format\&n=Rl78D_qJIpinmg19\&q=85\&s=a9d5db4bdc8f5bfd1460c09f46d5392f)

Later steps can use the value as `{{account_number}}`. See [Variables](https://docs.tryhamsa.com/agents/variables/overview.md).

While capture is on for a step:

* Only `*` and `#` can be picked for its **DTMF input** transitions ("Only \* and # are available as termination keys when DTMF capture is enabled"), and at most two of them.
* Existing number key transitions on the step are turned off: "This number key transition is disabled because DTMF input capture is enabled. Disable DTMF capture to use this transition."

## How it works on a call

* Keys work only on the step the call is in, and only while it waits for the caller.
* Any key press stops the agent if it's speaking.
* A key that matches one of the step's **DTMF input** transitions moves the call at once. Before it moves, the step's **Variable on node exit** variables are taken from the conversation so far.
* With capture on, any other key is added to the digits typed so far. When the caller presses the finishing key, the digits are saved to the variable, the agent sees them in the conversation as "\[keypad input: 12345]", and the call moves on.
* Without capture, a key with no matching transition is ignored.
* Each time the call enters a step, the typed digits start empty.

## Test it

In a browser test call, click **Keypad** in the call controls to press keys. See [Test your agent](https://docs.tryhamsa.com/agents/release/test-your-agent.md).

## Good to know

* A key press can't start a global step. To offer the same key everywhere (for example 0 for a person), add a **DTMF input** transition with that key on each step where the caller may press it. See [Global steps](https://docs.tryhamsa.com/agents/flow/global-steps.md).
* If the caller never presses the finishing key, the digits are lost when the call leaves the step. Mention the finishing key in the step's message.
* Digits are saved as text, so leading zeros are kept.

## Related

> [card] [Transitions](https://docs.tryhamsa.com/agents/flow/transitions.md)
>
> All transition types and how they're chosen.

> [card] [Conversation step](https://docs.tryhamsa.com/agents/flow/steps/conversation.md)
>
> Messages, interruption and variables.

> [card] [Start step](https://docs.tryhamsa.com/agents/flow/steps/start.md)
>
> The first step of every flow.

> [card] [Test your agent](https://docs.tryhamsa.com/agents/release/test-your-agent.md)
>
> Use the keypad in a browser test call.


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