> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # detect > Detect answering machines, fax tones, or digits on a call. [detectaction]: /docs/server-sdks/reference/typescript/relay/actions [calling-call-detect]: /docs/server-sdks/reference/typescript/relay/call#events [call-events]: /docs/server-sdks/reference/typescript/relay/call#events Start audio detection on the call. Detects answering machines, fax tones, or DTMF digits. Returns a [`DetectAction`][detectaction] that resolves on the first detection result or when the operation finishes. > **Note** > > The `DetectAction` resolves on the **first detection result**, not when the > detect operation finishes. This means `await action.wait()` returns as soon as > a result is available. > **Info** > > This method emits [`calling.call.detect`][calling-call-detect] events. See [Call Events][call-events] for payload details. ## **Parameters** **`detect`** `Record` — required Detection configuration object. --- **`detect.type`** `string` — required Detection type. Valid values: * `"machine"` -- answering machine detection (AMD) * `"fax"` -- fax tone detection (CNG/CED) * `"digit"` -- DTMF digit detection --- **`detect.params`** `Record` Type-specific detection parameters. --- **`timeout`** `number | undefined` Maximum seconds to run the detector before stopping. --- **`controlId`** `string | undefined` Custom control ID. Auto-generated if not provided. --- **`onCompleted`** `(event: RelayEvent) => void | Promise` Callback invoked when detection completes. --- ## **Returns** `Promise<`[`DetectAction`][detectaction]`>` -- An action handle with `stop()` and `wait()` methods. ## **Example** ```typescript {13} import { RelayClient } from '@signalwire/sdk'; const client = new RelayClient({ project: process.env.SIGNALWIRE_PROJECT_ID!, token: process.env.SIGNALWIRE_API_TOKEN!, contexts: ['default'] }); client.onCall(async (call) => { await call.answer(); // Answering machine detection const action = await call.detect( { type: 'machine', params: {} }, { timeout: 30 } ); const event = await action.wait(); const detectResult = event.params.detect as Record ?? {}; if (detectResult.type === 'machine') { console.log('Answering machine detected'); await call.hangup(); } else { console.log('Human answered'); const playAction = await call.play([{ type: 'tts', text: 'Hello! This is a call from...' }]); await playAction.wait(); } }); await client.run(); ``` > Detect answering machines, fax tones, or digits on a call.