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

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_TOKEN!,
6 contexts: ['default']
7});
8
9client.onCall(async (call) => {
10 await call.answer();
11 const action = await call.detect({
12 type: 'machine',
13 params: { initialTimeout: 5.0 },
14 });
15
16 const event = await action.wait(10000);
17 const detectResult = event.params.detect ?? {};
18 console.log(`Detected: ${JSON.stringify(detectResult)}`);
19});
20
21await client.run();