***

title: waitForUser
slug: /reference/typescript/agents/function-result/wait-for-user
description: Control how the agent pauses and waits for user input.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result

Control how the agent pauses and waits for the user to speak. The arguments
are evaluated in priority order: `answer_first` takes precedence, then
`timeout`, then `enabled`. If none are provided, waiting is enabled with no
timeout.

## **Parameters**

<ParamField path="opts" type="object" toc={true}>
  Optional configuration object.
</ParamField>

<Indent>
  <ParamField path="opts.enabled" type="boolean" toc={true}>
    Explicitly enable (`true`) or disable (`false`) waiting for user input.
  </ParamField>

  <ParamField path="opts.timeout" type="number" toc={true}>
    Number of seconds to wait for the user to speak before the agent continues.
  </ParamField>

  <ParamField path="opts.answerFirst" type="boolean" toc={true}>
    When `true`, activates the special `"answer_first"` mode. This answers the
    call and waits for the user to speak before the agent begins its greeting.
  </ParamField>
</Indent>

## **Returns**

[`FunctionResult`][functionresult] -- `this`, for chaining.

## **Examples**

### Enable waiting (no timeout)

```typescript {4}
import { FunctionResult } from '@signalwire/sdk';

const result = new FunctionResult('Take your time.')
  .waitForUser();
```

### Wait with timeout

```typescript {4}
import { FunctionResult } from '@signalwire/sdk';

const result = new FunctionResult('Please respond within 30 seconds.')
  .waitForUser({ timeout: 30 });
```

### Disable waiting

```typescript {4}
import { FunctionResult } from '@signalwire/sdk';

const result = new FunctionResult('Continuing without waiting.')
  .waitForUser({ enabled: false });
```