detectAnsweringMachine

View as MarkdownOpen in Claude

Detect whether a human or an answering machine picked up. A typed convenience over detect() with the machine detector.

Parameters

options
object

Detector options. Each maps to the matching snake_case param of the detect() command’s machine detector type.

options.initialTimeout
number

Seconds to wait for initial voice before deciding.

options.endSilenceTimeout
number

Seconds of silence that end the greeting.

options.machineVoiceThreshold
number

Seconds of continuous voice that indicate a machine.

options.machineWordsThreshold
number

Word count that indicates a machine.

options.detectInterruptions
boolean

Report interruptions during the greeting.

options.detectMessageEnd
boolean

Keep detecting until the machine’s greeting ends, so you can leave a message.

options.timeout
number

Maximum seconds to run the detector before stopping.

options.onCompleted
(event: RelayEvent) => void | Promise<void>

Callback invoked when the operation reaches a terminal state.

Returns

Promise<DetectAction> — An action handle with stop() and wait() methods. It resolves on the first detection result.

Example

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();
const action = await call.detectAnsweringMachine({ detectMessageEnd: true, timeout: 30 });
const event = await action.wait();
console.log(event.params);
});
await client.run();