DetectAction

View as MarkdownOpen in Claude

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

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.

Inherits all properties and methods from the base Action interface (controlId, isDone, completed, result, wait()).

Properties

No additional properties beyond the base Action interface.

Methods

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.detect({
type: 'machine',
params: { initialTimeout: 5.0 },
});
const event = await action.wait(10);
const detectResult = event.params.detect ?? {};
console.log(`Detected: ${JSON.stringify(detectResult)}`);
});
await client.run();