***

title: DetectAction
slug: /reference/typescript/relay/actions/detect-action
description: Action handle for an active detection operation.
max-toc-depth: 3
---------------------

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

[call-detect]: /docs/server-sdks/reference/typescript/relay/call/detect

[base-action-interface]: /docs/server-sdks/reference/typescript/relay/actions

[stop]: /docs/server-sdks/reference/typescript/relay/actions/detect-action/stop

Returned from [`call.detect()`][call-detect]. Tracks
an active detection operation (answering machine, fax tone, or digit detection).
Terminal states: `finished`, `error`.

<Note>
  Unlike other actions, `DetectAction` also resolves on the first detection result,
  not just on terminal state events. This means `await action.wait()` returns as
  soon as a detection is made.
</Note>

Inherits all properties and methods from the
[base Action interface][base-action-interface] (`controlId`,
`isDone`, `completed`, `result`, `wait()`).

## **Properties**

No additional properties beyond the [base Action interface][base-action-interface].

## **Methods**

<CardGroup cols={2}>
  <Card title="stop" href="/docs/server-sdks/reference/typescript/relay/actions/detect-action/stop">
    Stop detection immediately.
  </Card>
</CardGroup>

## **Example**

```typescript {11}
import { RelayClient } from '@signalwire/sdk';

const client = new RelayClient({
  project: process.env.SIGNALWIRE_PROJECT_ID!,
  token: process.env.SIGNALWIRE_TOKEN!,
  contexts: ['default']
});

client.onCall(async (call) => {
  await call.answer();
  const action = await call.detect({
    type: 'machine',
    params: { initialTimeout: 5.0 },
  });

  const event = await action.wait(10000);
  const detectResult = event.params.detect ?? {};
  console.log(`Detected: ${JSON.stringify(detectResult)}`);
});

await client.run();
```